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

Dialogs should trap focus #4384

Closed
pathsny opened this issue May 30, 2016 · 7 comments
Closed

Dialogs should trap focus #4384

pathsny opened this issue May 30, 2016 · 7 comments
Labels
duplicate This issue or pull request already exists

Comments

@pathsny
Copy link

pathsny commented May 30, 2016

Problem description

When a dialog is drawn with multiple elements, keyboard navigation allows the user to switch focus. But when the last element is focused and tab is hit, focus should switch back to the first element.

Steps to reproduce

Create a dialog with a few fields. Use tab to switch focus till the last element. Hit tab once again3

Versions

  • Material-UI: 0.15.0
  • React: 15.1.0
  • Browser: Chrome, 50.0.2661.102
@muibot muibot added the Triage label May 30, 2016
@mbrookes mbrookes added accessibility a11y and removed Triage labels May 30, 2016
@mbrookes
Copy link
Member

Ref #61.

@matthewoates
Copy link
Contributor

Big 👍 to this.

I played around with https://github.com/davidtheclark/focus-trap-react last weekend and it nearly works as a drop-in replacement.

a few caveats:

  • only one focus-trap can be active at a time (might need special logic for multiple simultaneous dialogues)
  • the library errors if there is not a focusable element
  • the auto-focus built into the library (which is slightly redundant given autoFocus functionality, autoFocus and initialFocus focus-trap/focus-trap-react#3) automatically focuses an element via query

@nathanmarks
Copy link
Member

nathanmarks commented Jun 1, 2016

@matthewoates I have a dialog ready which solves this issue (and also improves the dialog component structure and API). It is using react-overlays as we're considering some of the features to help improve our overlay/layering system holistically.

I'll be submitting my dialog refactor PR for consideration after I finish working on some style related things -- I thought I would mention in case you wanted to focus your efforts on another area.

@mbrookes we need to setup that roadmap!

Also, this is a dupe of #156

@nathanmarks nathanmarks added the duplicate This issue or pull request already exists label Jun 1, 2016
@niquola
Copy link

niquola commented Jul 1, 2016

How about autocomplete & focus?

@jingchan
Copy link

jingchan commented Dec 8, 2017

Was there a regression for this issue? Dialogs do not seem to trap focus for me.

@marie-hughes
Copy link

They don't for me either.

@harinair
Copy link

harinair commented Feb 27, 2018

They seem to have just closed the issue without fixing it or it might have regressed. It does not work. I opened a new issue #10458.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

10 participants