Skip to content

Commit 000b0fe

Browse files
committed
Address feedback
Address feedback
1 parent 80f695d commit 000b0fe

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

packages/react-dom/src/events/DOMPluginEventSystem.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -747,13 +747,16 @@ export function accumulateSinglePhaseListeners(
747747
// this out by checking if intercept fiber set on the event matches the
748748
// current instance fiber. In which case, we should clear all existing
749749
// listeners.
750-
if (
751-
enableCreateEventHandleAPI &&
752-
nativeEvent.type === 'beforeblur' &&
750+
if (enableCreateEventHandleAPI && nativeEvent.type === 'beforeblur') {
753751
// $FlowFixMe: internal field
754-
nativeEvent._detachedInterceptFiber === instance
755-
) {
756-
listeners = [];
752+
const detachedInterceptFiber = nativeEvent._detachedInterceptFiber;
753+
if (
754+
detachedInterceptFiber !== null &&
755+
(detachedInterceptFiber === instance ||
756+
detachedInterceptFiber === instance.alternate)
757+
) {
758+
listeners = [];
759+
}
757760
}
758761
instance = instance.return;
759762
}

packages/react-dom/src/events/__tests__/DOMPluginEventSystem-test.internal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2425,7 +2425,7 @@ describe('DOMPluginEventSystem', () => {
24252425
});
24262426

24272427
// @gate experimental
2428-
it('beforeblur has the correct propagation mechancis after a nested focused element is unmounted', () => {
2428+
it('beforeblur should skip handlers from a deleted subtree after the focused element is unmounted', () => {
24292429
const onBeforeBlur = jest.fn();
24302430
const innerRef = React.createRef();
24312431
const innerRef2 = React.createRef();
@@ -2565,7 +2565,7 @@ describe('DOMPluginEventSystem', () => {
25652565
});
25662566

25672567
// @gate experimental
2568-
it('beforeblur has the correct propagation mechancis after a nested focused element is suspended', () => {
2568+
it('beforeblur should skip handlers from a deleted subtree after the focused element is suspended', () => {
25692569
const onBeforeBlur = jest.fn();
25702570
const innerRef = React.createRef();
25712571
const innerRef2 = React.createRef();

packages/react-reconciler/src/ReactFiberWorkLoop.new.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2172,7 +2172,7 @@ function commitBeforeMutationEffectsImpl(fiber: Fiber) {
21722172
doesFiberContain(fiber, focusedInstanceHandle)
21732173
) {
21742174
shouldFireAfterActiveInstanceBlur = true;
2175-
beforeActiveInstanceBlur(current);
2175+
beforeActiveInstanceBlur(fiber);
21762176
}
21772177
}
21782178

packages/react-reconciler/src/ReactFiberWorkLoop.old.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2271,7 +2271,7 @@ function commitBeforeMutationEffects() {
22712271
doesFiberContain(nextEffect, focusedInstanceHandle)
22722272
) {
22732273
shouldFireAfterActiveInstanceBlur = true;
2274-
beforeActiveInstanceBlur(current);
2274+
beforeActiveInstanceBlur(nextEffect);
22752275
}
22762276
}
22772277
}

0 commit comments

Comments
 (0)