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

Keyboard Accessible MenuItems and VolumeMenuButton #1519

Merged
merged 3 commits into from
Sep 30, 2014
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/css/video-js.less
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,8 @@ easily in the skin designer. http://designer.videojs.com/
}

.vjs-default-skin .vjs-menu {
Copy link
Member

Choose a reason for hiding this comment

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

Instead of making changes to the CSS for all menus is there a way we could use the vjs-volume-menu-button class and make updates only to that?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, that seems better than what's there now.

display: none;
z-index: -1;
Copy link
Member

Choose a reason for hiding this comment

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

I think we could use the hide-visually mix-in here instead of z-index. There's potential that a menu button component could be used somewhere where the menu wouldn't be covered by the the player.

Copy link
Author

Choose a reason for hiding this comment

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

The .vjs-default-skin .vjs-menu selector is going back to using display: none based on your previous comment. So I don't it should be using hide-visually.
I don't think it makes sense to use visually-hidden for the volume bar, because then we have to manually undo all of the styles it entails and repeat styles we've already created.
Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, it doesn't make sense to use it on .vjs-menu with the other change.

I was mainly looking for an alternative to z-index for hiding it. Would height:0 or width: 0 work? That seems to basically be what youtube is doing. Alternatively we could add a .visuallyhidden class that contains the hide-visually styles, and add/remove that class to/from the volume slider when needed.

Copy link
Author

Choose a reason for hiding this comment

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

I'm a little hesitant on the .visuallyhidden idea (although I experimented with it and does work alright). My first concern is that we also need to listen to hover in code rather than css. Secondly, I kinda like being able to use the lock/unlockShowing methods on menu, as opposed to manually adding/removing classes.

The width: 0 works a bit better. It winds up being more css because you have to explicitly style the vjs-menu-content as well as the vjs-menu. However, I think this might be a better solution. I'm gonna try to clean my experiments up and push them up.
Sound good?

display: block;
position: absolute;
bottom: 0;
left: 0em; /* (Width of vjs-menu - width of button) / 2 */
Expand All @@ -732,6 +733,11 @@ easily in the skin designer. http://designer.videojs.com/
border-top-color: rgba(7, 40, 50, 0.5); /* Same as ul background */
}

.vjs-default-skin .vjs-control-content .vjs-menu {
z-index: 0;
display: none;
}

/* Button Pop-up Menu */
.vjs-default-skin .vjs-menu-button .vjs-menu .vjs-menu-content {
display: block;
Expand All @@ -748,7 +754,11 @@ easily in the skin designer. http://designer.videojs.com/
.box-shadow(-0.2em -0.2em 0.3em rgba(255, 255, 255, 0.2));
}

.vjs-default-skin .vjs-menu-button:hover .vjs-menu {
.vjs-default-skin .vjs-menu-button:hover .vjs-menu,
.vjs-default-skin .vjs-menu-button .vjs-menu.vjs-lock-showing {
z-index: 1;
}
.vjs-default-skin .vjs-control-content .vjs-menu.vjs-lock-showing {
display: block;
}
.vjs-default-skin .vjs-menu-button ul li {
Expand Down
6 changes: 6 additions & 0 deletions src/js/control-bar/volume-menu-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ vjs.VolumeMenuButton.prototype.createMenu = function(){
contentElType: 'div'
});
var vc = new vjs.VolumeBar(this.player_, vjs.obj.merge({'vertical': true}, this.options_.volumeBar));
Copy link
Member

Choose a reason for hiding this comment

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

@gkatsev I'm realizing that the volume menu button is broken by default because vertical is true by default here and nothing else is set up to handle that. If I set it to false it makes it work. Does the BC version set this to true somewhere or would that change break things?

Copy link
Member

Choose a reason for hiding this comment

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

why would it be broken here? Seems to be working fine for us. It used to be broken when vertical wasn't quoted.

Copy link
Member

Choose a reason for hiding this comment

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

When I test this PR and try to drag the volume handle with my mouse, the bar is horizontal but the mouse movement needs to be vertical. Are you seeing something different? To be clear, I think this issue existed before this PR.

Copy link
Member

Choose a reason for hiding this comment

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

And by test I mean open /sandbox/index.html

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see. There needs to be extra CSS that rotates it.

vc.on('focus', function() {
menu.lockShowing();
});
vc.on('blur', function() {
menu.unlockShowing();
});
menu.addChild(vc);
return menu;
};
Expand Down
1 change: 0 additions & 1 deletion src/js/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,3 @@ vjs.MenuButton.prototype.unpressButton = function(){
this.menu.unlockShowing();
this.el_.setAttribute('aria-pressed', false);
};