Skip to content

Commit 4e70062

Browse files
committed
Address feedback
1 parent 80f695d commit 4e70062

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -747,13 +747,15 @@ 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 === instance ||
755+
detachedInterceptFiber === instance.alternate
756+
) {
757+
listeners = [];
758+
}
757759
}
758760
instance = instance.return;
759761
}

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();

0 commit comments

Comments
 (0)