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

autoFocus and initialFocus #3

Closed
matthewoates opened this issue May 26, 2016 · 2 comments
Closed

autoFocus and initialFocus #3

matthewoates opened this issue May 26, 2016 · 2 comments

Comments

@matthewoates
Copy link

You get autoFocus for free. My understanding is that whenever a focusable element with autoFocus is added by react, it automatically gets focused.

autoFocus doesn't work right now with focus-trap-react.

  • If initialFocus is unspecified, it ignores any autoFocus elements and focuses the first element.
  • If you pass a selector that matches no elements, focus-trap-react throws an error and breaks the component.
  • If you pass a valid selector, then you're not taking advantage of the convenience and simplicity of autoFocus in the first place
@davidtheclark
Copy link
Collaborator

Makes sense. I'd say that "the convenience and simplicity of autoFocus" is really not significantly greater than typing a valid selector for the component you want to focus — but if that's how you like to do it, I understand. Open to a PR making this autoFocus-compatible.

@davidtheclark
Copy link
Collaborator

@matthewoates With the latest update to focus-trap, autoFocus does in fact work. I added a demo showing this and a note to the README explaining the one caveat I've seen.

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

No branches or pull requests

2 participants