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(dropdown): improve accessibility #905

Merged
merged 4 commits into from
Sep 29, 2020
Merged

Conversation

Westbrook
Copy link
Contributor

@Westbrook Westbrook commented Sep 25, 2020

Description

Update the accessibility tree of the Dropdown pattern and its derivative components (ActionMenu and SplitButton) as well as the Menu pattern that they leverage internally.

Preview available: https://5f6e5921adb59e0095ccb7c2--spectrum-web-components.netlify.app/

This does:

  • correct the focus target of open "dropdowns" to ensure that VO (macOS, iOS) enters/announces their content correctly
  • moves from using :focus to [focused] to ensure transient visual state
  • matches tests to these patterns
  • updates to the latest aXe-core release
    • adjust usage of role="group" as per its updated rules
  • populates MenuItems with ids when missing
  • differentiates functionality between options and menuitems
  • uses div elements over buttons in <sp-menu-item>

This does NOT:

  • use the role=combobox pattern
    • will follow up in the area when we have better information on making this x-browser compliant and a path to supporting the requirement of a textfield as a child of this role
  • handle moving backward in the tab order in iOS and leaving the overlay
  • applying size and count attributes

Related Issue

fixes #764
refs #292
fixes #908

Motivation and Context

Components should be accessible x-browser, x-context, etc.

How Has This Been Tested?

  • aXe-core unit testing
  • manually review with macOS and iOS VO features
  • visual regressions

Screenshots (if appropriate):

image
image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@Westbrook Westbrook force-pushed the westbrook/a11y-dropdown branch 2 times, most recently from b09b4f0 to d03d62c Compare September 26, 2020 18:02
Copy link
Collaborator

@adixon-adobe adixon-adobe left a comment

Choose a reason for hiding this comment

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

A couple of questions that might lead to a few more changes. Overall looks great!

@@ -63,13 +63,11 @@ export class Menu extends SpectrumElement {
}

public focus(): void {
if (this.menuItems.length === 0) {
if (!this.menuItems.length) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did you need this change -- is this just a code style choice, or is there something subtle I'm missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just style, I had removed this check at one point and then re-added it not knowing the style changed. There may be some slight amount of type security outside of the TS space in the small fraction of time this.menuItems === undefined, but I don't know enough V8/timing to confirm.

${this.buttonContent}
</div>
`;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hadn't realized this extended from ActionButton -- neat. Whenever something like a core render method is overridden I try to think about maintainability. Since the only difference is the tag name, is that something you could parameterize?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could make the source render method more composable so that we only have to override part of it:

protected render(): TemplateResult {
    return this.isAnchor ?  this.renderAnchor : this.renderButton;
}
protected get renderAnchor() {}
protected get renderButton() {}

That's probably nicer system wide, I'll take swing at it.

@Westbrook
Copy link
Contributor Author

@adixon-adobe this has been updated. It's got a couple of settings and changes that it would be good to have in #912 to speed/stabilize the CI process while we lock down the docs/visual regression cache. Let me know if you see any other good suggestions herein!

Copy link
Collaborator

@adixon-adobe adixon-adobe left a comment

Choose a reason for hiding this comment

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

Looks good -- thanks!

@Westbrook Westbrook merged commit 0d8f12a into main Sep 29, 2020
@Westbrook Westbrook deleted the westbrook/a11y-dropdown branch September 29, 2020 18:46
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.

Menu shows focus border on click in safari Dropdown does not take focus when opens w/ iOS + VO
2 participants