-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Replay capture phase for continuous events #22680
Replay capture phase for continuous events #22680
Conversation
04d2106
to
fb47c18
Compare
Comparing: 4ff5f57...bfe8062 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
4f77598
to
e7cc04d
Compare
8a7e8c8
to
236af6c
Compare
packages/react-dom/src/__tests__/ReactDOMServerSelectiveHydration-test.internal.js
Show resolved
Hide resolved
…aseContinuousEvents
…aseContinuousEvents
6e5bdcb
to
6bf50cb
Compare
} | ||
} else { | ||
// This tree has been unmounted already. Dispatch without a target. | ||
return nullTarget; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't come up with a test case where we findInstanceBlockingEvent
would return nullTarget
. It doesn't seem possible that it would ever happen because it would mean that there is a React Instance defined on the target but then nearestMountedFiber
returns null
for this case. I added a test which attempted to simulate this by removing the target node from its react tree into a tree where there is no react root but that didn't seem to work.
getClosestInstanceFromNode(getEventTarget(queuedEvent.nativeEvent))
did return null
for this case though.
Based off how hydration works it shouldn't be possible for the nearestMountedFiber
to ever be anything other than a SuspenseInstance
. Unless the node is manually moved in userland to a different tree thats already hydrated, I tried doing that but that also didn't trigger the nullTarget
. I'm unsure what else to try to trigger it. Any ideas?
83a3868
to
ea448a4
Compare
ea448a4
to
a88e173
Compare
Merged via #22856. |
Summary
We want to replay the capture phase for continuous events on hydration (currently we only replay the bubble phase).
This will allow us to call
stopPropagation()
in the capture phase to prevent the bubble phase.With this change we also use the browsers native event dispatching to replay events. This allows stopPropagation in the capture phase to actually stop the bubble phase from firing without needing to hook into the native event / simulating the capture / bubble phase in a single phase.
Quirks:
mouseout
(normally) andmouseover
(replay). (existing behavior)stopPropagation
during the capture phase ofmouseout
would normally preventmouseenter
/mouseleave
listeners from firing (Codesandbox showing this existing behavior: https://codesandbox.io/s/silly-microservice-n3vv1?file=/src/App.js) but since before this PR we didn't replay the capture phase there was no way to stop it during replaying.stopPropagation
during the capture phase ofmouseover
would preventmouseenter
(Replay usesmouseover
to emulatemouseEnter
because we don't replaymouseout
events, perhaps we could replay them in a special way for replay where we actually ignore them from simpleEventPlugin if they're being replayed).mouseout
is never replayed somouseleave
is also never replayed (existing behavior)I included these changes under the existing
enableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay
so that I don't need a new experiment and since we want to enable all of these changes togetherHow did you test this change?
jest