Repository navigation
fix: deliver raw touch events past a declining touch responder - #1958
Open
RaphaelFakhri wants to merge 1 commit into
Open
RaphaelFakhri wants to merge 1 commit into
RaphaelFakhri wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1957.
fireEvent(element, 'touchStart')skips theonTouchStartof an ancestor when the nearest touch responder below it declines the touch (onStartShouldSetResponderreturnsfalse). The same applies totouchMove,touchEndandtouchCancel. 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 attachonStartShouldSetResponderto a wrapperViewin their Jest mocks, such as the hook gesture detector in React Native Gesture Handler 3, make every raw touch under them unreachable from ancestors.isEventEnablednow returnstruefor raw touch events before it applies the responder check. ThepointerEventsand non-editableTextInputchecks run first and are unchanged. Responder-driven events likepressstill respect a declining responder, which the existingdoes not warn when the responder declines the touchtest covers.The change also adds a
CHANGELOG.mdentry under "Unreleased".Test plan
src/events/__tests__/fire-event.test.tsx(responder system):touchStart,touchMove,touchEndandtouchCancelreach a parent handler when the child declines the responder.touchStartreaches the handler on the element that declines the responder.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 lintandyarn format:checkpass.