-
Notifications
You must be signed in to change notification settings - Fork 64
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
Focus trap Doesn't work on (dev) React strict mode #704
Comments
Thanks. I believe this will be resolved by fixing #77 |
stefcameron
added a commit
that referenced
this issue
Jun 10, 2022
Fixes #77 Fixes #704 For the longest time, since before I took over, we were filtering specified containers through `ReactDOM.findDOMNode()`, but why? The configured trap containers (via the `containerElements` prop) must be elements already, which means they must already be rendered, which means there's no point in passing them through `findDOMNode()` to find an underlying DOM element because they aren't React elements in the first place. The removal of this call should mean that React Strict Mode will finally be OK with focus-trap-react. Note it's still possible to render a focus trap with a single React element child. That works fine, and never needed `findDOMNode()` anyway. We were already using a callback ref to get its element to then auto-configure that element as the single container for the focus trap. Just to be sure, however, this will be released as a new __major__ version.
Hoping #710 will fix this. |
stefcameron
added a commit
that referenced
this issue
Jun 10, 2022
Fixes #77 Fixes #704 For the longest time, since before I took over, we were filtering specified containers through `ReactDOM.findDOMNode()`, but why? The configured trap containers (via the `containerElements` prop) must be elements already, which means they must already be rendered, which means there's no point in passing them through `findDOMNode()` to find an underlying DOM element because they aren't React elements in the first place. The removal of this call should mean that React Strict Mode will finally be OK with focus-trap-react. Note it's still possible to render a focus trap with a single React element child. That works fine, and never needed `findDOMNode()` anyway. We were already using a callback ref to get its element to then auto-configure that element as the single container for the focus trap. Just to be sure, however, this will be released as a new __major__ version.
Look for a fix to this (I hope!!) in v9.0.0 being published right now. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
React Version: 18.1.0
The focus trap doesn't seem to work at all. If you disable strict mode or build it, it works normally.
The text was updated successfully, but these errors were encountered: