mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 02:23:58 +00:00
Restore selection after keyboard parameter navigation
When blurring out of keyboard parameter navigation, the last-selected parameter will be highlighted again. Bug: T312017 Change-Id: I8b0fb667b44b324529d4c45c39bf21573517f989
This commit is contained in:
parent
441ffc5a84
commit
787d44af66
|
@ -7,6 +7,7 @@
|
|||
* @constructor
|
||||
* @param {Object} config
|
||||
* @cfg {ve.ui.MWTransclusionOutlineParameterWidget[]} items
|
||||
* @property {string|null} currentHighlight
|
||||
*/
|
||||
ve.ui.MWTransclusionOutlineParameterSelectWidget = function VeUiMWTransclusionOutlineParameterSelectWidget( config ) {
|
||||
// Parent constructor
|
||||
|
@ -24,7 +25,7 @@ ve.ui.MWTransclusionOutlineParameterSelectWidget = function VeUiMWTransclusionOu
|
|||
this.$element
|
||||
.on( {
|
||||
focus: this.bindDocumentKeyDownListener.bind( this ),
|
||||
blur: this.unbindDocumentKeyDownListener.bind( this )
|
||||
blur: this.onBlur.bind( this )
|
||||
} );
|
||||
|
||||
// FIXME: Workaround to prevent the hover effect, because it causes explicit
|
||||
|
@ -105,6 +106,7 @@ ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.findFirstSelectedItem
|
|||
* @param {string} [paramName] Parameter name to highlight, e.g. "param1". Omit for no highlight.
|
||||
*/
|
||||
ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.highlightParameter = function ( paramName ) {
|
||||
this.currentHighlight = paramName;
|
||||
var item = this.findItemFromData( paramName );
|
||||
// Intentionally drop any highlighting if the parameter can't be found
|
||||
this.highlightItem( item );
|
||||
|
@ -113,6 +115,15 @@ ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.highlightParameter =
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle blur event by reapplying "select" highlighting.
|
||||
*/
|
||||
ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.onBlur = function () {
|
||||
this.unbindDocumentKeyDownListener();
|
||||
var item = this.findItemFromData( this.currentHighlight );
|
||||
this.highlightItem( item );
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} paramName
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue