Skip to content

fix: deliver raw touch events past a declining touch responder - #1958

Open
RaphaelFakhri wants to merge 1 commit into
callstack:mainfrom
RaphaelFakhri:fix/touch-events-ignore-responder
Open

RaphaelFakhri wants to merge 1 commit into
callstack:mainfrom
RaphaelFakhri:fix/touch-events-ignore-responder

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Summary

Fixes #1957.

fireEvent(element, 'touchStart') skips the onTouchStart of an ancestor when the nearest touch responder below it declines the touch (onStartShouldSetResponder returns false). The same applies to touchMove, touchEnd and touchCancel. On a device, raw touch events are not part of responder negotiation: they reach every ancestor of the touched view whether or not a view accepts the responder. Libraries that attach onStartShouldSetResponder to a wrapper View in their Jest mocks, such as the hook gesture detector in React Native Gesture Handler 3, make every raw touch under them unreachable from ancestors.

isEventEnabled now returns true for raw touch events before it applies the responder check. The pointerEvents and non-editable TextInput checks run first and are unchanged. Responder-driven events like press still respect a declining responder, which the existing does not warn when the responder declines the touch test covers.

The change also adds a CHANGELOG.md entry under "Unreleased".

Test plan

  • New tests in src/events/__tests__/fire-event.test.tsx (responder system):
    • touchStart, touchMove, touchEnd and touchCancel reach a parent handler when the child declines the responder.
    • touchStart reaches the handler on the element that declines the responder.
  • Without the source change: yarn jest src/events/__tests__/fire-event.test.tsx -t "responder system" reports 5 failed, 2 passed. With it: 7 passed.
  • yarn test:ci: 87 suites, 954 tests passed.
  • yarn typecheck, yarn lint and yarn format:check pass.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fireEvent doesn't deliver raw touch events to an ancestor when a view below declines the responder

1 participant