mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Start with last item when shift+tabbing into parameter list
Note this implementation introduces some technical debt: It adds a little bit of knowledge about what "part widgets" and the toolbar are to the parameter SelectWidget. I think this is acceptable. A "cleaner" implementation is probably so complicated that we don't want it in the code, for such a minor benefit. However, alternative patches are very much welcome. Bug: T313703 Change-Id: I957698d58a7622cbe54bcc2ba454388ba9f09537
This commit is contained in:
parent
54d0268847
commit
eb71810b6d
|
@ -169,10 +169,25 @@ ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.onCheckboxChange = fu
|
||||||
* @inheritDoc OO.ui.SelectWidget
|
* @inheritDoc OO.ui.SelectWidget
|
||||||
*/
|
*/
|
||||||
ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.onFocus = function ( event ) {
|
ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.onFocus = function ( event ) {
|
||||||
if ( event.target === this.$element[ 0 ] && !this.findHighlightedItem() ) {
|
if ( event.target !== this.$element[ 0 ] || this.findHighlightedItem() ) {
|
||||||
// When tabbing into the selection list, highlight the first parameter.
|
return;
|
||||||
this.highlightItem( this.items[ 0 ] );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var index = 0;
|
||||||
|
if ( event.relatedTarget ) {
|
||||||
|
var toolbarClass = 've-ui-mwTransclusionOutlineControlsWidget',
|
||||||
|
// The only elements below a parameter list can be another part or the toolbar
|
||||||
|
selector = '.ve-ui-mwTransclusionOutlinePartWidget, .' + toolbarClass,
|
||||||
|
$fromPart = $( event.relatedTarget ).closest( selector ),
|
||||||
|
$toPart = $( event.target ).closest( selector );
|
||||||
|
// When shift+tabbing into the list, highlight the last parameter
|
||||||
|
// eslint-disable-next-line no-jquery/no-class-state
|
||||||
|
if ( $fromPart.hasClass( toolbarClass ) || $fromPart.index() > $toPart.index() ) {
|
||||||
|
index = this.getItemCount() - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.highlightItem( this.items[ index ] );
|
||||||
|
|
||||||
// Don't call the parent. It makes assumptions what should be done here.
|
// Don't call the parent. It makes assumptions what should be done here.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue