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 keyboard ux, WAI-ARIA #1293

Merged

Conversation

eckdanny-osi
Copy link
Contributor

Closes #1287

  • Bug fix
  • New feature
  • Chore
  • Breaking change
  • There is an open issue which this change addresses
  • I have read the CONTRIBUTING document.
  • My commits follow the Git Commit Guidelines
  • 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 added tests to cover my changes.
  • All new and existing tests passed.

Adds additional event-handlers and focus management for the Dropdown component.

  • focus is placed on the first menuitem on expand1
  • only space/enter opens the menu
  • up/down arrow keyDown wraps2 (optional)
  • home/end keys jump to first/last item2
  • tab/space/esc returns focus to the menu button and closes the menu1

dropdown-pr

src/Dropdown.js Outdated Show resolved Hide resolved
src/Dropdown.js Show resolved Hide resolved
<DropdownItem disabled>Action</DropdownItem>
<DropdownItem>Another Action</DropdownItem>
<DropdownItem>Some Action</DropdownItem>
<DropdownItem disabled>Action (disabled)</DropdownItem>
Copy link
Member

Choose a reason for hiding this comment

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

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"[Another] Action" all start with 'a'

Wanted to better demonstrate the "jump to 1st matching char" feature

@eckdanny-osi
Copy link
Contributor Author

Tnx for the review @TheSharpieOne. I thought maybe this PR was dead in the water b/c it deviates from BS4 behavior. I'll address your feedback as soon as i have time

@TheSharpieOne
Copy link
Member

TheSharpieOne commented Dec 6, 2018

I think a11y trumps bootstrap alignment (at least a little). Plus most people will not even notice the difference and if they do, I'm sure they will be happy that it is more accessible.

Update event handlers

* wrap next/prev
* handle ctrl+n/ctrl+p
* handle home/end
* manage focus on aria-expand/collapse
* docs(Dropdown): reword action buttons
* return Array<Element> (not NodeList) in getMenuItems

return an array of els, not NodeList
@eckdanny-osi
Copy link
Contributor Author

@TheSharpieOne addressed change requests, rebased, ready for final check. If you disagree re docs/lib/examples/Dropdown.js, i'll strip it out.

@TheSharpieOne TheSharpieOne merged commit 506c46a into reactstrap:master Dec 12, 2018
@eckdanny-osi eckdanny-osi deleted the fix-dropdown-keyboard-nav branch December 12, 2018 21:45
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.

Any character opens Dropdown menu
2 participants