-
Notifications
You must be signed in to change notification settings - Fork 64
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.
- Loading branch information
1 parent
8beb07e
commit 2b16d5b
Showing
7 changed files
with
91 additions
and
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
require('./demo-defaults'); | ||
require('./demo-animated-dialog'); | ||
require('./demo-animated-trigger'); | ||
require('./demo-ffne'); | ||
// require('./demo-defaults'); | ||
// require('./demo-animated-dialog'); | ||
// require('./demo-animated-trigger'); | ||
// require('./demo-ffne'); | ||
require('./demo-special-element'); | ||
require('./demo-autofocus'); | ||
require('./demo-containerelements'); | ||
require('./demo-containerelements-childless'); | ||
require('./demo-setReturnFocus'); | ||
require('./demo-iframe'); | ||
require('./demo-with-shadow-dom'); // TEST MANUALLY (Cypress doesn't support Shadow DOM well) | ||
// require('./demo-autofocus'); | ||
// require('./demo-containerelements'); | ||
// require('./demo-containerelements-childless'); | ||
// require('./demo-setReturnFocus'); | ||
// require('./demo-iframe'); | ||
// require('./demo-with-shadow-dom'); // TEST MANUALLY (Cypress doesn't support Shadow DOM well) |
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