[#77] Finally drop use of findDOMNode()#710
Merged
stefcameron merged 1 commit intomasterfrom Jun 10, 2022
Merged
Conversation
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.
🦋 Changeset detectedLatest commit: 4e6929c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This was referenced Jun 10, 2022
Codecov Report
@@ Coverage Diff @@
## master #710 +/- ##
==========================================
- Coverage 92.76% 92.66% -0.10%
==========================================
Files 1 1
Lines 152 150 -2
Branches 65 65
==========================================
- Hits 141 139 -2
Misses 11 11
Continue to review full report at Codecov.
|
Closed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
containerElementsprop)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.
PR Checklist
Please leave this checklist in your PR.
typeof document/window !== 'undefined'before using it in code that gets executed on load.yarn changesetlocally to add one, and follow the prompts).