Florianschmidtwelzow has uploaded a new change for review. https://gerrit.wikimedia.org/r/251527
Change subject: LookupElement: Make auto-highlighting the first term configurable ...................................................................... LookupElement: Make auto-highlighting the first term configurable Sometimes, there is no need (or/and it's explicitly not wished), that the first term of a LookupElement is highlighted (and therefore added to the input field, if the Return key was pressed). Make this feature configurable with a new "highlight" config, which defaults to true. Bug: T106273 Change-Id: I36502da43c38337307d671b2e45c69846e07aa61 --- M demos/pages/widgets.js M src/mixins/LookupElement.js 2 files changed, 17 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/27/251527/1 diff --git a/demos/pages/widgets.js b/demos/pages/widgets.js index a531d7f..235f434 100644 --- a/demos/pages/widgets.js +++ b/demos/pages/widgets.js @@ -56,11 +56,11 @@ * @extends OO.ui.TextInputWidget * @mixins OO.ui.mixin.LookupElement */ - function NumberLookupTextInputWidget() { + function NumberLookupTextInputWidget( config ) { // Parent constructor OO.ui.TextInputWidget.call( this, { validate: 'integer' } ); // Mixin constructors - OO.ui.mixin.LookupElement.call( this ); + OO.ui.mixin.LookupElement.call( this, config ); } OO.inheritClass( NumberLookupTextInputWidget, OO.ui.TextInputWidget ); OO.mixinClass( NumberLookupTextInputWidget, OO.ui.mixin.LookupElement ); @@ -1574,6 +1574,15 @@ } ), new OO.ui.FieldLayout( + new NumberLookupTextInputWidget( { + highlight: false + } ), + { + label: 'LookupElement without highlighting 1st term (try inputting an integer)\u200E', + align: 'top' + } + ), + new OO.ui.FieldLayout( new OO.ui.ProgressBarWidget( { progress: 33 } ), diff --git a/src/mixins/LookupElement.js b/src/mixins/LookupElement.js index 27f05c0..9636dd3 100644 --- a/src/mixins/LookupElement.js +++ b/src/mixins/LookupElement.js @@ -24,7 +24,9 @@ */ OO.ui.mixin.LookupElement = function OoUiMixinLookupElement( config ) { // Configuration initialization - config = config || {}; + config = config || { + highlight: true + }; // Properties this.$overlay = config.$overlay || this.$element; @@ -41,6 +43,7 @@ this.lookupRequest = null; this.lookupsDisabled = false; this.lookupInputFocused = false; + this.lookupHighlightItem = config.highlight; // Events this.$input.on( { @@ -228,13 +231,13 @@ }; /** - * Highlight the first selectable item in the menu. + * Highlight the first selectable item in the menu, if configured. * * @private * @chainable */ OO.ui.mixin.LookupElement.prototype.initializeLookupMenuSelection = function () { - if ( !this.lookupMenu.getSelectedItem() ) { + if ( this.lookupHighlightItem && !this.lookupMenu.getSelectedItem() ) { this.lookupMenu.highlightItem( this.lookupMenu.getFirstSelectableItem() ); } }; -- To view, visit https://gerrit.wikimedia.org/r/251527 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I36502da43c38337307d671b2e45c69846e07aa61 Gerrit-PatchSet: 1 Gerrit-Project: oojs/ui Gerrit-Branch: master Gerrit-Owner: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits