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

Stops top menu item being triggered when opening the menu using the keyboard #1447

Merged
merged 0 commits into from Sep 3, 2014

Conversation

mynameisstephen
Copy link

Fixes #1446

Key press handler is only active when either the MenuButton has focus or the Menu is open (allows closing the menu when a menu item is selected).

// This function is not needed anymore. Instead, the keyboard functionality is handled by
// treating the button as triggering a submenu. When the button is pressed, the submenu
// appears. Pressing the button again makes the submenu disappear.
vjs.MenuButton.prototype.onFocus = function(){};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this removed to re-enable the button focus listeners?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, we only want to listen when we have focus.

@heff heff added the bug label Aug 26, 2014
@@ -200,6 +191,7 @@ vjs.MenuButton.prototype.onKeyPress = function(event){
};

vjs.MenuButton.prototype.pressButton = function(){
this.on('keyup', this.onKeyPress);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having trouble following the logic here. It looks like the onKeyPress listener calls pressButton which then adds the onKeyPress listener. I think that might duplicate the listener.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to readd the listener to get bubble key press events from the menu item so we can close the menu. Ideally we would have the menu trigger an event when it is activated and deactivated.

If you look further down the function the first menu item is focused on, this will remove the menubutton's keyup listener set in the button focus listeners. Looking at the code now, it might be better to move this keyup listener to inside that if statement, so it is only set if there are menu items.

@heff
Copy link
Member

heff commented Aug 26, 2014

I think this might be related to the deeper issue of event bubbling unexpectedly in #1452. So I think we should probably address that first, at least to make sure it doesn't affect this.

@mynameisstephen
Copy link
Author

I looked into #1452 it seems to work fine on FireFox and Chrome on windows 8. Could be an osx thing?

@heff
Copy link
Member

heff commented Aug 27, 2014

I just merged #1452 into master. Do you want to try that out and see if it changes this issue for you at all? Or are you saying you already tried that?

@heff
Copy link
Member

heff commented Sep 2, 2014

@mynameisstephen we're working on a release. Any new info on this one?

@mynameisstephen
Copy link
Author

Still an issue with the #1452 fix. Also tried changing the MenuButton code in master to use keydown events but that still causes issues.

@heff heff merged commit 7d4b266 into videojs:master Sep 3, 2014
@mynameisstephen
Copy link
Author

Hmm this didn't merge properly. Maybe because I moved the fix to a branch - https://github.com/mynameisstephen/video.js/tree/menubutton-fix - should I submit another pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Triggering the MenuButton using the keyboard cause the top menu item to be triggered.
2 participants