-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
fix: only change focus from BPB if not a mouse click #4497
fix: only change focus from BPB if not a mouse click #4497
Conversation
src/js/button.js
Outdated
constructor(player, options) { | ||
super(player, options); | ||
|
||
this._mouseused = false; |
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.
Is there a reason this property name doesn't follow other conventions? Most of the time, it's camel case with a trailing underscore (i.e. mouseUsed_
).
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.
I didn't remember where we put the _
. I'll move it to the end.
src/js/big-play-button.js
Outdated
@@ -36,6 +36,11 @@ class BigPlayButton extends Button { | |||
handleClick(event) { | |||
const playPromise = this.player_.play(); | |||
|
|||
// exit early if clicked via the mouse | |||
if (this._mouseused && event.clientX && 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.
Could we just use clientX
or clientY
without mouseused
here? could be a terrible idea but I figured I would throw it out there.
src/js/button.js
Outdated
constructor(player, options) { | ||
super(player, options); | ||
|
||
this._mouseused = false; |
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.
Is there any reason not stick this in BigPlayButton
instead of the Button
class?
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.
You're right. That would be better since I want this as self contained as possible.
This is a simple change to not change the focus to the play toggle from the Big Play Button when clicking on it with the mouse.
There's still work to be done with regards to the focus ring and mouse vs key events but that's for another time and would probably be more involved.
We cancel out focus changing if the mouse was used to click the button, or, as far as we could tell via the
mousedown
handler. Unfortunately, using VoiceOver's functionality (via control-option space), we also get amousedown
event. However, those events do not addclientX
andclientY
to theclick
event like a true mouse event does.