Permalink
Browse files

Mouse: Ignore `mousemove` events triggered by key presses in Safari

If the user presses control, meta, shift, or alt during a drag operation,
Safari will trigger an event where `event.which` is `0`. We use that scenario
to detect that a `mouseup` occurred in a different document, so we need to
ignore these events when one of the keys are pressed.

Fixes #14461
Closes gh-1620
  • Loading branch information...
scottgonzalez committed Oct 17, 2015
1 parent 60fa118 commit 17b5386e8cb48c522ddb581a001fef5434e57f9a
Showing with 11 additions and 1 deletion.
  1. +11 −1 ui/widgets/mouse.js
View
@@ -146,7 +146,16 @@ return $.widget( "ui.mouse", {
// Iframe mouseup check - mouseup occurred in another document
} else if ( !event.which ) {
- return this._mouseUp( event );
+
+ // Support: Safari <=8 - 9
+ // Safari sets which to 0 if you press any of the following keys
+ // during a drag (#14461)
+ if ( event.originalEvent.altKey || event.originalEvent.ctrlKey ||
+ event.originalEvent.metaKey || event.originalEvent.shiftKey ) {
+ this.ignoreMissingWhich = true;
+ } else if ( !this.ignoreMissingWhich ) {
+ return this._mouseUp( event );
+ }
}
}
@@ -188,6 +197,7 @@ return $.widget( "ui.mouse", {
delete this._mouseDelayTimer;
}
+ this.ignoreMissingWhich = false;
mouseHandled = false;
event.preventDefault();
},

0 comments on commit 17b5386

Please sign in to comment.