-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#720] Add strict mode compatibility
Fixes #720 In React strict mode, the trap gets immediately unmounted and remounted after first mount. The trap deactivates automatically on unmount, so on remount, we try to restore the trap to its previous active/paused state based on the component's existing state. React does not re-render the component, nor does it call callback refs again, so we have no choice but to assume the DOM hasn't changed and the existing trap's container elements are still in the DOM... Way to go React for strict mode violating the assumption of `componentWillUnmount()`, "Once a component is unmounted, it will never be mounted again." Not a fan. Also bumped react-dom to 18.2.0 since react was already there, and set NODE_ENV for different builds.
- Loading branch information
1 parent
8beb07e
commit 6d2c92c
Showing
6 changed files
with
81 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'focus-trap-react': patch | ||
--- | ||
|
||
Fix an issue when running in strict mode which has React immediately unmount/remount the trap, causing it to deactivate and then have to reactivate (per existing component state) on the remount. [#720](https://github.com/focus-trap/focus-trap-react/issues/720) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters