-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blocks: Don't show the block toolbar if we press ctrl, shift... on Safari #1365
Conversation
Lovely Safari. |
51a7cdd
to
9765b32
Compare
Where is the logic that normally prevents it for meta keys? |
@iseulde We just check the mouse position compared to the previous mouse position. that way, we ensure we're effectively moving the mouse |
@youknowriad No I mean, in other browsers, currently in master, what prevents the UI from showing up on shift or ctrl etc.? |
On other browsers this event is not triggered at all when we hit shift, ctrl... |
Ok, I see. Allow me to quickly see if there's no other solution. |
You're right, I thought maybe we could prevent default behaviour somehow. |
editor/modes/visual-editor/block.js
Outdated
this.props.onStopTyping(); | ||
this.lastClientX = event.clientX; | ||
this.lastClientY = event.clientY; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this to avoid duplicate assignment?
stopTypingOnMouseMove( { clientX, clientY } ) {
const { lastClientX, lastClientY } = this;
// We need to check that the mouse really moved
// Because Safari trigger mousemove event when we press shift, ctrl...
if ( lastClientX && lastClientY && ( lastClientX !== clientX || lastClientY !== clientY ) ) {
this.props.onStopTyping();
}
this.lastClientX = clientX;
this.lastClientY = clientY;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM updating
9765b32
to
3c6a904
Compare
closes #1349
It appears that safari trigger an "mousemove" event when we click on the meta keys (shift, ctrl...) even if the mouse didn't move. Some details on the weird mousemove event in Safari here https://transitory.technology/mouse-move-in-safari/
The workaround here is to check that the mouse position effectively changed before showing the toolbar.