Skip to content

Commit

Permalink
ComboBoxInputWidget: Only show menu on user triggered events
Browse files Browse the repository at this point in the history
The idea is to open the dropdown menu only when the user interacts
with the element, not every time setValue is called. onEdit is
the event handler that's triggered on keyup and such. It calls
setValue, where the dropdown menu was toggled before. So the
"only" change in this patch is that the menu is toggled a bit
earlier, and not in a separate thread any more (menu.toggle is
now executed outside of the setTimeout in InputWidget.onEdit).

Bug: T261314
Change-Id: I6693fc861dbadc2601e7b62198775deabe67d20c
  • Loading branch information
thiemowmde authored and edg2s committed Aug 26, 2020
1 parent 29dc0c7 commit a9a0faa
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/widgets/ComboBoxInputWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,18 @@ OO.ui.ComboBoxInputWidget.prototype.getInput = function () {
return this;
};

/**
* @inheritdoc
*/
OO.ui.ComboBoxInputWidget.prototype.onEdit = function () {
// Parent method
OO.ui.ComboBoxInputWidget.super.prototype.onEdit.apply( this, arguments );

if ( !this.menu.isVisible() && !this.isDisabled() && this.isVisible() ) {
this.menu.toggle( true );
}
};

/**
* Handle input change events.
*
Expand All @@ -178,10 +190,6 @@ OO.ui.ComboBoxInputWidget.prototype.onInputChange = function ( value ) {
if ( this.menu.findHighlightedItem() ) {
this.menu.highlightItem( match );
}

if ( !this.isDisabled() ) {
this.menu.toggle( true );
}
};

/**
Expand Down

0 comments on commit a9a0faa

Please sign in to comment.