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 the structure of elements in menus to comply with ARIA requirements #4034

Merged
merged 4 commits into from
Feb 8, 2017

Conversation

OwenEdwards
Copy link
Member

Description

The previous (v5.x) menu structure violated an ARIA requirement, that actionable elements (e.g. the menu button) not have child elements which are also actionable (e.g. the menu items). This PR changes that structure to make "MenuButton" actually a <div> containing a <button> and a menu. The v5.x structure, and the use of role="group" on the Control Bar, were a workaround which made the menus work with most screen readers, but the structure might fail in future screen readers.

This change is very similar to the change to the combined volume from v5 -> v6.

Specific Changes proposed

Restructure the HTML elements in a MenuButton & Menu; change the Javascript to handle this. Also, remove unnecessary aria-label attribute on the MenuButton, since the actual button used to open the menu is now correctly labeled by the controlText.

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
    • Change has been verified in an actual browser (Chome, Firefox, IE)
    • Unit Tests updated or fixed
  • Reviewed by Two Core Contributors

@OwenEdwards OwenEdwards added the a11y This item might affect the accessibility of the player label Feb 6, 2017
Copy link
Member

@misteroneill misteroneill left a comment

Choose a reason for hiding this comment

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

LGTM

@OwenEdwards OwenEdwards mentioned this pull request Feb 6, 2017
7 tasks
gkatsev
gkatsev previously requested changes Feb 6, 2017
Copy link
Member

@gkatsev gkatsev left a comment

Choose a reason for hiding this comment

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

This is awesome.

One thing I noticed when testing, if I'm just using the keyboard, tabbing into the menu and opening it, and then selecting an item works great. However, after selecting an item, when the captions menu closes, it'll require pressing space twice to open it up again.

this.update();

this.enabled_ = true;

this.el_.setAttribute('aria-haspopup', 'true');
this.el_.setAttribute('role', 'menuitem');
this.menuButton_.on('tap', Fn.bind(this, this.handleClick));
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 you can change this to:

this.on(this.menuButton_, 'tap', this.handleClick);

*
* @method handleFocus
*/
handleFocus() {
Copy link
Member

Choose a reason for hiding this comment

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

not that we need to right now, but I think we need a keyhandler-mixin.

@OwenEdwards
Copy link
Member Author

I think these two commits fix all of the issues @gkatsev pointed out.

@OwenEdwards OwenEdwards dismissed gkatsev’s stale review February 7, 2017 20:02

Asked @gkatsev to review again, based on additional commits to address his points

@gkatsev gkatsev merged commit 1b1ba04 into videojs:master Feb 8, 2017
* @return {string}
* The constructed wrapper DOM `className`
*/
buildWrapperCSSClass() {
Copy link
Member

Choose a reason for hiding this comment

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

I just realized that the change to this buildWrapperCSSClass means that the elements lose out on having something like vjs-captions-button applied to the main wrapper element.

I think we want to return something like

return `${buttonClass} ${super.buildCSSClass()} ${this.buildCSSClass()}`;

instead, since the components are generally already set up with buildCSSClass to return the correct thing.

I'll open an issue for this.

gkatsev added a commit that referenced this pull request Mar 2, 2017
In #4034, we changed the way that menu buttons work slightly by introduction a wrapper element with a separate wrapper css builder. However, this broke, at least the playback-rate menu.
This PR adds a buildWrapperCSSClass to each of our menu buttons.
@OwenEdwards OwenEdwards deleted the fix/menu-structure-for-ARIA branch March 4, 2017 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y This item might affect the accessibility of the player
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants