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

Dropdown a11y updates #3586

Merged
merged 21 commits into from
Aug 5, 2019

Conversation

elizabethsjudd
Copy link
Contributor

@elizabethsjudd elizabethsjudd commented Jul 30, 2019

Closes: #1147

Update to Dropdown for a11y.

Changelog

Changed

  • Dropdown HTML is updated for a11y considerations using semantic tags, aria attributes, and role attributes
  • Added styles for the new structure
  • JavaScript updated to use new structure and support aria-activedescendant

Testing / Reviewing

  • regression test the dropdown for all users types (screen reader, keyboard, mouse)

@netlify
Copy link

netlify bot commented Jul 30, 2019

Deploy preview for carbon-components-react ready!

Built with commit 42d2d73

https://deploy-preview-3586--carbon-components-react.netlify.com

@netlify
Copy link

netlify bot commented Jul 30, 2019

Deploy preview for the-carbon-components ready!

Built with commit 42d2d73

https://deploy-preview-3586--the-carbon-components.netlify.com

@netlify
Copy link

netlify bot commented Jul 30, 2019

Deploy preview for carbon-elements ready!

Built with commit 42d2d73

https://deploy-preview-3586--carbon-elements.netlify.com

@elizabethsjudd
Copy link
Contributor Author

@carbon-design-system/developers is there a reason dropdown has the data-floating-menu-direction="bottom" attribute but doesn't use FloatingMenu in the scripts?

@asudoh asudoh requested a review from a team July 30, 2019 22:19
@ghost ghost requested review from laurenmrice and removed request for a team July 30, 2019 22:19
Copy link
Contributor

@asudoh asudoh left a comment

Choose a reason for hiding this comment

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

Looks mostly markup change so it looks good from dev perspective, adding @carbon-design-system/design to ensure the visual is still good.

@elizabethsjudd
Copy link
Contributor Author

@asudoh can you answer this question: #3586 (comment)? It won't be part of this PR but it impacts the stuff that I'm working on now for Dropdown menu

@laurenmrice
Copy link
Member

Screen Shot 2019-07-31 at 10 31 02 AM

Is this focus on the whole drawer browser determined when it comes to the styling of it? Because it looks different from our regular focus @elizabethsjudd

@elizabethsjudd
Copy link
Contributor Author

@laurenmrice

Right now default browser focus is visible on the menu but that will be corrected in the next PR.

the fix for that is going to come in the next PR. The whole menu technically gets focus but then we'll use the aria-activedescendent attribute to navigate the dropdown which will give the menu items the appearance of focus. I'm almost done with the next PR (hoping EOD today or sometime tomorrow).

@elizabethsjudd
Copy link
Contributor Author

@asudoh @laurenmrice The updates to the JavaScript wasn't that much so I combined my two branches in to this single PR.

@elizabethsjudd elizabethsjudd changed the title Dropdown a11y HTML updates Dropdown a11y updates Jul 31, 2019
@asudoh
Copy link
Contributor

asudoh commented Jul 31, 2019

Quick answer on your floating menu question (sorry @elizabethsjudd for missing this!) - The attribute seems to have been added by mistake - Dropdown is not a floating menu, and my quick look tells me that dropdown code/style (still) does not refer to that attribute.

Copy link
Contributor

@asudoh asudoh left a comment

Choose a reason for hiding this comment

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

Good progress @elizabethsjudd!

packages/components/src/components/dropdown/dropdown.js Outdated Show resolved Hide resolved
packages/components/src/components/dropdown/dropdown.js Outdated Show resolved Hide resolved
packages/components/src/components/dropdown/dropdown.js Outdated Show resolved Hide resolved
@elizabethsjudd
Copy link
Contributor Author

@asudoh I've updated the code based on your comments.

Copy link
Contributor

@asudoh asudoh left a comment

Choose a reason for hiding this comment

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

Just one last comment in code. Would you be able to add test cases that represents the enhancement you did? Thanks @elizabethsjudd!

if (this.element.querySelector(this.options.selectorTrigger)) {
const listNode = this.element.querySelector(this.options.selectorMenu);
const focusedId = listNode.getAttribute('aria-activedescendant');
focusedNode = focusedId ? listNode.querySelector(`#${focusedId}`) : null;
Copy link
Contributor

Choose a reason for hiding this comment

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

getElementById()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@asudoh getElementById only works from the document object which is why I opted for querySelector here. I do believe that I could use this.element.ownerDocument.getElementById here though if you'd prefer that.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK thank you for clarifying @elizabethsjudd! - Makes sense as-is.

Copy link
Contributor

@asudoh asudoh left a comment

Choose a reason for hiding this comment

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

LGTM 👍 - Thanks @elizabethsjudd for all the updates and tests!

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

Successfully merging this pull request may close these issues.

Dropdown needs accessibility improvements
5 participants