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

React modal incorrectly restores input focus on unmount (React 16) #675

Open
denich opened this issue Aug 1, 2018 · 0 comments
Open

React modal incorrectly restores input focus on unmount (React 16) #675

denich opened this issue Aug 1, 2018 · 0 comments
Milestone

Comments

@denich
Copy link

denich commented Aug 1, 2018

Summary:

When conditional render is used - react modal restores focus on unmount without triggering onFocus event handler on target input.

Steps to reproduce:

  1. Add <Modal />
  2. Focus some input
  3. Mount/unmount the modal
  4. Focus restored w/o triggering onFocus event handler on the input

Expected behavior:

Input's onFocus event handler is triggered on focus restore.

Link to example of issue:

React16 and v3: https://codesandbox.io/s/6y6nx2np4k

Additional notes:

  • It works in case of using isOpen attribute instead of conditional rendering
  • It works with v2 and React15 in case closeTimeoutMS is set (I think v3 don't respect closeTimeoutMS on unmount anymore #530 issue prevents using this workaround)
  • It works in case restore focus in timeout

In case of using for example draft-js as an input, this bug becomes a cause of the really strange behavior after focus restore.

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