Skip to content

[0.88] Fix responder events when dispatching to unmounted components - #60467

Open
rubennorte wants to merge 3 commits into
react:0.88-stablefrom
rubennorte:0.88-backport-responder-unmounted-target
Open

rubennorte wants to merge 3 commits into
react:0.88-stablefrom
rubennorte:0.88-backport-responder-unmounted-target

Conversation

@rubennorte

Copy link
Copy Markdown
Member

Summary:

Backport of the fix for reactwg/react-native-releases#1490 to 0.88-stable, as requested in reactwg/react-native-releases#1490 (comment).

With EventTarget-based event dispatching (enabled by default in 0.88), events targeting an unmounted view were dropped before reaching the responder system. As a result, the responder was never released and the next tap was lost.

Commits, cherry-picked with -x:

  1. f754dbd (Process responder events for touches whose target unmounted #59522): Process responder events for touches whose target unmounted. Adapted: on 0.88-stable, dispatchNativeEvent passes target directly to processResponderEvent and dispatchTrustedEvent, without the internalTarget cast. That cast was added on main in 652d501 (Use global DOM types in Fantom tests (#58569) #58569), which isn't on this branch. The resolution widens target to ?EventTarget and returns early when target == null. It doesn't bring in the cast.
  2. eb90a8d (Sync OSS Fabric renderers for null-target native events (#59546) #59546): Sync OSS Fabric renderers for null-target native events. Applied cleanly; the renderer files on 0.88-stable match this commit's parent exactly.
  3. eaf4c26 (Run the unmounted-touch responder test with both dispatch systems (#59545) #59545): Run the unmounted-touch responder test with both dispatch systems. Applied cleanly (test only).

Changelog:

[GENERAL] [FIXED] - Fix lost taps and stuck responders after a touched view unmounts when EventTarget event dispatching is enabled

Test Plan:

  • yarn flow check: no errors
  • yarn eslint / yarn prettier --check on the changed files: clean
  • Fantom: on this branch ResponderEventTarget-itest.js is skipped in OSS (isOSS ? describe.skip : describe), so I removed the skip locally (not committed) and ran:
    • yarn fantom ResponderEventTarget-itest: 50/50 pass. The new test "releases the responder when the touched view unmounts before the touch ends" passes with enableNativeEventTargetEventDispatching both on and off.
    • Same suite with the dispatchNativeEvent/responder/renderer changes reverted: the new test fails, and so does "dispatches responderTerminate on touch cancel" presumably because the stuck responder carries over into it.
    • yarn fantom EventDispatching-itest: passes.

lazerg and others added 2 commits December 2, 2026 11:04
)

Summary:
With `enableNativeEventTargetEventDispatching` on, a touch that ends after its view unmounted never reaches the responder, so the old responder sticks around and `trackedTouchCount` stays one too high, which drops the next tap. `processResponderEvent` already handles a null target, but `dispatchNativeEvent` only accepts a non-null one and would crash in `dispatchTrustedEvent` if it got null. It now takes `EventTarget | null` and returns right after the responder step when there is no target. The renderer's `dispatchEvent` (`ReactFabricEventEmitter.js` in react/react) still skips the call for a null target, so that guard has to go too before the bug is fully fixed, and this change needs to land first.

Fixes react#59519

[GENERAL] [FIXED] - Fix the responder not being released when a touch ends after its view unmounted

Pull Request resolved: react#59522

Test Plan: Added a Fantom test to `ResponderEventTarget-itest.js` that grants the responder, sends `topTouchEnd` with a null target through `dispatchNativeEvent`, and checks that the release fires and the next touch is granted again. I couldn't build the Fantom runner locally, so I also ran the null-target case as a throwaway Jest test: on `main` it throws `TypeError: Cannot read properties of null` from `dispatchTrustedEvent`, and it passes with this change. `flow check`, eslint and prettier are clean.

Reviewed By: javache

Differential Revision: D127796330

Pulled By: rubennorte

fbshipit-source-id: 3c3547998b3b079a540e8cdf8e904ee95a855515
(cherry picked from commit f754dbd)
Summary:

Regenerate the development, production, and profiling Fabric renderer bundles from React revision `dc9aed364252a34966f4f2c4a98272317fdddb60`. Native events whose view has unmounted now reach the responder system even when their event target is null.

This renderer-only update retains React version `19.3.0` and leaves package metadata and dependency versions unchanged.

Changelog:
[General][Fixed] - Fix lost taps after a touched view unmounts when EventTarget event dispatching is enabled

Reviewed By: javache

Differential Revision: D127828293

Pull Request resolved: react#59546

(cherry picked from commit eb90a8d)
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 2, 2026
@facebook-github-tools facebook-github-tools Bot added p: Facebook Partner: Facebook Partner labels Dec 2, 2026
…act#59545)

Summary:

Remove the flag-dependent skip from the Fantom regression test for a touched view unmounting before its touch ends. Fabric now forwards native events with a null target, so both dispatch systems must release the stale responder and grant the next touch.

Keep the existing `enableNativeEventTargetEventDispatching:*` test matrix and remove the unused feature-flag import and obsolete TODO.

Changelog: [Internal]

___

landed-with-radar-review

Differential Revision: D127828380

Pull Request resolved: react#59545

(cherry picked from commit eaf4c26)
@cortinico

Copy link
Copy Markdown
Contributor

CI is red because of a previous commit on the release branch, this fixes it:

@gabrieldonadel

gabrieldonadel commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

@rubennorte Nico's fix for CI already landed; do you mind rebasing this PR?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner Pick Request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants