Skip to content
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

Merged
merged 7 commits into from
Jul 26, 2017

Conversation

gkatsev
Copy link
Member

@gkatsev gkatsev commented Jul 17, 2017

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 a mousedown event. However, those events do not add clientX and clientY to the click event like a true mouse event does.

@gkatsev gkatsev changed the title fix: only change focus from BPB if via keypress fix: only change focus from BPB if not a mouse click Jul 17, 2017
src/js/button.js Outdated
constructor(player, options) {
super(player, options);

this._mouseused = false;
Copy link
Member

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_).

Copy link
Member Author

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.

@@ -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) {
Copy link
Contributor

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;
Copy link
Contributor

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?

Copy link
Member Author

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.

@gkatsev gkatsev merged commit ee014e2 into videojs:master Jul 26, 2017
@gkatsev gkatsev deleted the dont-change-focus-via-mouse-bpb branch July 26, 2017 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants