Bartosz Dziewoński has uploaded a new change for review.
https://gerrit.wikimedia.org/r/269157
Change subject: SelectWidget: Prevent mouse highlighting while typing-to-select
......................................................................
SelectWidget: Prevent mouse highlighting while typing-to-select
Chromium's Blink engine will generate spurious 'mouseover' events during
programmatic scrolling and around 100-150 ms after it is finished.
I am pretty sure this violates some specs, but I don't really feel
like spec-lawyering with its developers.
I miss the times when the only browser with broken event handling was IE 6.
Bug: T125740
Change-Id: I4b95935027cec699c0460f4ddf1fb9f6b3c97064
---
M src/widgets/SelectWidget.js
1 file changed, 26 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/57/269157/1
diff --git a/src/widgets/SelectWidget.js b/src/widgets/SelectWidget.js
index 8f579ca..bdc7e33 100644
--- a/src/widgets/SelectWidget.js
+++ b/src/widgets/SelectWidget.js
@@ -60,6 +60,7 @@
this.onKeyPressHandler = this.onKeyPress.bind( this );
this.keyPressBuffer = '';
this.keyPressBufferTimer = null;
+ this.stopSpuriousMouseHighlights = 0;
// Events
this.connect( this, {
@@ -223,7 +224,9 @@
*/
OO.ui.SelectWidget.prototype.onMouseOver = function ( e ) {
var item;
-
+ if ( this.stopSpuriousMouseHighlights ) {
+ return;
+ }
if ( !this.isDisabled() ) {
item = this.getTargetItem( e );
this.highlightItem( item && item.isHighlightable() ? item :
null );
@@ -294,7 +297,7 @@
} else {
this.chooseItem( nextItem );
}
- nextItem.scrollElementIntoView();
+ this.scrollItemIntoView( nextItem );
}
if ( handled ) {
@@ -321,6 +324,26 @@
*/
OO.ui.SelectWidget.prototype.unbindKeyDownListener = function () {
this.getElementWindow().removeEventListener( 'keydown',
this.onKeyDownHandler, true );
+};
+
+/**
+ * Scroll item into view, preventing spurious mouse highlight actions from
happening.
+ *
+ * @return {OO.ui.OptionWidget} Item to scroll into view
+ * @param {boolean} [immediate] Whether to scroll with no animation
+ */
+OO.ui.SelectWidget.prototype.scrollItemIntoView = function ( item ) {
+ var widget = this;
+ // Chromium's Blink engine will generate spurious 'mouseover' events
during programmatic scrolling
+ // and around 100-150 ms after it is finished.
+ this.stopSpuriousMouseHighlights++;
+ item.scrollElementIntoView( {
+ complete: function () {
+ setTimeout( function () {
+ widget.stopSpuriousMouseHighlights--;
+ }, 200 );
+ }
+ } );
};
/**
@@ -385,7 +408,7 @@
} else {
this.chooseItem( item );
}
- item.scrollElementIntoView();
+ this.scrollItemIntoView( item );
}
return false;
--
To view, visit https://gerrit.wikimedia.org/r/269157
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4b95935027cec699c0460f4ddf1fb9f6b3c97064
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