Bartosz Dziewoński has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/231396

Change subject: MenuSelectWidget: Call #updateItemVisibility in more cases
......................................................................

MenuSelectWidget: Call #updateItemVisibility in more cases

Binding to only 'keypress' misses some situations where the value
changes. A noticeable one is pressing Backspace (which doesn't seem to
fire 'keypress' at all, only 'keydown'), but also right click paste,
and so on.

Use the same list of events which we use in InputWidget, and which so
far has served us well. This is already debounced, so there's no worry
about multiple events per key press.

Change-Id: I73068664dd9be7f7aacbcdbdbed8c6b072935eb5
---
M src/widgets/MenuSelectWidget.js
1 file changed, 4 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/96/231396/1

diff --git a/src/widgets/MenuSelectWidget.js b/src/widgets/MenuSelectWidget.js
index 40c3690..0a85e3a 100644
--- a/src/widgets/MenuSelectWidget.js
+++ b/src/widgets/MenuSelectWidget.js
@@ -54,7 +54,7 @@
        this.$input = config.$input ? config.$input : config.input ? 
config.input.$input : null;
        this.$widget = config.widget ? config.widget.$element : null;
        this.onDocumentMouseDownHandler = this.onDocumentMouseDown.bind( this );
-       this.onInputKeyPressHandler = OO.ui.debounce( 
this.updateItemVisibility.bind( this ), 100 );
+       this.onInputEditHandler = OO.ui.debounce( 
this.updateItemVisibility.bind( this ), 100 );
 
        // Initialization
        this.$element
@@ -125,7 +125,7 @@
 };
 
 /**
- * Update menu item visibility after input key press
+ * Update menu item visibility after input changes.
  * @protected
  */
 OO.ui.MenuSelectWidget.prototype.updateItemVisibility = function () {
@@ -173,7 +173,7 @@
 OO.ui.MenuSelectWidget.prototype.bindKeyPressListener = function () {
        if ( this.$input ) {
                if ( this.filterFromInput ) {
-                       this.$input.on( 'keypress', this.onInputKeyPressHandler 
);
+                       this.$input.on( 'keydown mouseup cut paste change input 
select', this.onInputEditHandler );
                }
        } else {
                
OO.ui.MenuSelectWidget.parent.prototype.bindKeyPressListener.call( this );
@@ -186,7 +186,7 @@
 OO.ui.MenuSelectWidget.prototype.unbindKeyPressListener = function () {
        if ( this.$input ) {
                if ( this.filterFromInput ) {
-                       this.$input.off( 'keypress', 
this.onInputKeyPressHandler );
+                       this.$input.off( 'keydown mouseup cut paste change 
input select', this.onInputEditHandler );
                        this.updateItemVisibility();
                }
        } else {

-- 
To view, visit https://gerrit.wikimedia.org/r/231396
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I73068664dd9be7f7aacbcdbdbed8c6b072935eb5
Gerrit-PatchSet: 1
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to