Modern Event System: use focusin/focusout for onFocus/onBlur #19186
+45
−44
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit e8205ae:
|
I think this looks okay, obviously barring the JSDOM issue. |
packages/react-dom/src/events/plugins/ModernChangeEventPlugin.js
Outdated
Show resolved
Hide resolved
packages/react-dom/src/events/plugins/ModernChangeEventPlugin.js
Outdated
Show resolved
Hide resolved
1326bb2
to
04209cb
Seems ok but I don't see why we don't remove TOP_FOCUS and TOP_BLUR altogether. |
671aacc
to
ff22629
f709fb1
to
a196777
a6b4857
to
f812fda
Fix test now we use capture phase Cleanup Address feedback Revise Fix ReactDOMInput-test Fix
This was referenced Jul 13, 2020
a59f899
into
facebook:master
32 checks passed
32 checks passed
ci/circleci: RELEASE_CHANNEL_stable_yarn_test_prod_www_variant
Your tests passed on CircleCI!
Details
gaearon
added a commit
to gaearon/react
that referenced
this pull request
Jul 20, 2020
Thanks for this one, @trueadm ! |
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.
Note: this PR requires changes in JSDOM, otherwise Jest tests fail. Everything passes when I make the JSDOM changes locally. This PR also includes #19221.
Before the changes in this PR, we mapped
onFocus
andonBlur
tofocus
andblur
, but we did so in the capture phase. Doing so in the capture phase enables us to listen to all events as if they bubbled, which works great when you listen on thedocument
.With the modern event system, we no longer listen on the
document
for events, but rather with listen to the React root (or portal) container element. This means that if we listen tofocus
andblur
in the capture phase, they actually occur in reverse order, which can lead to inconsistent UIs ifonFocus
oronBlur
are used likefocusin
andfocusout
work (which we have recommended users to do in the past).This PR alters how the modern event system handles
onFocus
andonBlur
so that they now usefocusin
andfocusout
rather thanfocus
andblur
. This means we no longer need to listen to these events in the capture phase, ensuring consistentcy when usingonFocus
andonBlur
with the expectation that bubbling order should correctly traverse through containers as expected.In terms of breaking changes, this change will mean that React will not support Firefox versions earlier than 52. Earlier versions do not support
focusin
andfocusout
.