Aude has uploaded a new change for review. https://gerrit.wikimedia.org/r/199910
Change subject: Set _focusToValueView on entityselectorselected event in snakview ...................................................................... Set _focusToValueView on entityselectorselected event in snakview Renames _tabToValueView to _focusToValueView, and set this also for enter keydown and mousedown events for property input. With I6e694dd and possibly other recent snakview changes, keydown event now occurs after entityselectorselected. This meant that _tabToValueView is not set yet when entityselectorselected is executed and focus is never then set to the value input. I suppose perhaps this worked before because this check and the focus happened inside "self.options.entityStore.get( entityId ).done" so the timing worked. Bug: T93864 Change-Id: Id386edf0942f2378c11e24528a2957316099c91b --- M lib/resources/jquery.wikibase/snakview/snakview.js 1 file changed, 17 insertions(+), 28 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/10/199910/1 diff --git a/lib/resources/jquery.wikibase/snakview/snakview.js b/lib/resources/jquery.wikibase/snakview/snakview.js index d4ceb37..bcb9f52 100644 --- a/lib/resources/jquery.wikibase/snakview/snakview.js +++ b/lib/resources/jquery.wikibase/snakview/snakview.js @@ -121,12 +121,11 @@ _isInEditMode: false, /** - * Caching whether to move the focus from the `Property` input to the value input after pressing - * the TAB key. + * Caching whether to move the focus from the `Property` input to the value input after select. * @property {boolean} * @private */ - _tabToValueView: false, + _focusToValueView: false, /** * Whether then `snakview`'s value is regarded "valid" at the moment. @@ -248,7 +247,7 @@ } ) .prop( 'placeholder', mw.msg( 'wikibase-snakview-property-input-placeholder' ) ) .on( 'blur', function( event ) { - self._tabToValueView = false; + self._focusToValueView = false; } ) .on( 'eachchange', function( event, oldValue ) { // remove out-dated variations @@ -260,6 +259,19 @@ } } ) .on( 'entityselectorselected', function( e, entityId ) { + // When pressing TAB, ENTER or clicking in the property input element while the value + // input element does not yet exist, we assume that the user wants to + // auto-complete/select the currently suggested property and tab into the value + // element. Since the API needs to be queried to construct the correct value input, + // the intended action needs to be cached and triggered as soon as the value input + // has been created. + if ( event.keyCode == $.ui.keyCode.TAB + || event.keyCode == $.ui.keyCode.ENTER + || event.type == 'mousedown' + ) { + self._focusToValueView = true; + } + // Display spinner as long as the ValueView is loading: self.$snakValue.empty().append( $( '<div/>' ).append( $( '<span/>' ).addClass( 'mw-small-spinner' ) ) @@ -274,7 +286,7 @@ // Since it takes a while for the value view to gather its data from the API, // the property might not be valid anymore aborting the rendering of the value // view. - if( self._tabToValueView && self._variation ) { + if( self._focusToValueView && self._variation ) { $( self._variation ).one( 'afterdraw', function() { self._variation.focus(); } ); @@ -305,29 +317,6 @@ var self = this; this._isInEditMode = true; - - this.element.on( 'keydown.' + this.widgetName, function( event ) { - if ( self.options.disabled ) { - return; - } - - var propertySelector = self._getPropertySelector(); - - if ( event.keyCode === $.ui.keyCode.TAB && !self._variation ) { - event.stopPropagation(); - // When pressing TAB in the property input element while the value input element - // does not yet exist, we assume that the user wants to auto-complete/select the - // currently suggested property and tab into the value element. Since the API needs - // to be queried to construct the correct value input, the intended action needs to - // be cached and triggered as soon as the value input has been created. - if ( propertySelector && event.target === propertySelector.element[0] ) { - if( self._getPropertySelector().selectedEntity() ) { - self._tabToValueView = true; - event.preventDefault(); - } - } - } - } ); if( this._variation ) { $( this._variation ).one( 'afterstartediting', function() { -- To view, visit https://gerrit.wikimedia.org/r/199910 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id386edf0942f2378c11e24528a2957316099c91b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Aude <aude.w...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits