Skip to content

Conversation

@michaelkro
Copy link
Contributor

@michaelkro michaelkro commented Oct 19, 2018

Fixes #557

What

  • Introduces focus-trap-react dependency (documentation)
  • Fixes esc key interaction when there are multiple Dropdowns on the same page. Hitting the esc key will close the menu and return focus to that particular Dropdown's toggle. Previously, focus would get shifted to the last Dropdown on the screen

focus-trap-react

  • I found focus-trap-react while reading the Programmatically Managing Focus section in the React docs regarding a11y
  • The documentation mentions react-aria-modal as as "a great focus management example," the author of which also authored focus-trap-react

Focus Trap Resources

@michaelkro michaelkro added the PF4 label Oct 19, 2018
@michaelkro michaelkro force-pushed the 557-dropdown-keyboard-interaction branch from d9542a3 to 8f7f6f1 Compare October 19, 2018 12:43
@coveralls
Copy link

coveralls commented Oct 19, 2018

Pull Request Test Coverage Report for Build 2779

  • 1 of 3 (33.33%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.05%) to 81.148%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/patternfly-4/react-core/src/components/Dropdown/Toggle.js 0 2 0.0%
Totals Coverage Status
Change from base Build 2740: -0.05%
Covered Lines: 3435
Relevant Lines: 3991

💛 - Coveralls

- Fixes esc key interaction
- Introduces focus-trap-react

Fixes patternfly#557
@michaelkro michaelkro force-pushed the 557-dropdown-keyboard-interaction branch from 8f7f6f1 to 27faf90 Compare October 19, 2018 12:56
@patternfly-build
Copy link
Collaborator

PatternFly-React preview: https://815-pr-patternfly-react-patternfly.surge.sh

dgutride
dgutride previously approved these changes Oct 19, 2018
@michaelkro michaelkro changed the title [WIP] feat(PF4-Dropdown): Enhance keyboard interaction for a11y feat(PF4-Dropdown): Enhance keyboard interaction for a11y Oct 19, 2018
@jgiardino
Copy link
Contributor

Thanks for sharing the resources you found!

I tested this for the sighted keyboard-only experience, and it works as expected.

There are still some updates pending in #788 that alter the screen reader experience, which is blocking me from reviewing and confirming this works as expected across all screen readers.

const { parentRef } = this.props;
const keyCode = event.keyCode || event.which;
if (keyCode === 27) {
if (keyCode === 27 && parentRef && parentRef.contains(event.target)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a constant for the escape key defined in the internal/constants.js can we use that here?

@michaelkro michaelkro dismissed stale reviews from jeff-phillips-18 and dgutride via 81d79ea October 24, 2018 11:44
@patternfly-build
Copy link
Collaborator

Deploy preview for patternfly-react-gone ready!

Built with commit 81d79ea

https://deploy-preview-815--patternfly-react-gone.netlify.com

Copy link
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

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

LGTM

@tlabaj tlabaj merged commit cc89db6 into patternfly:master Oct 24, 2018
@michaelkro michaelkro deleted the 557-dropdown-keyboard-interaction branch October 24, 2018 20:15
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.

Dropdown keyboard interaction

8 participants