fix(button): prevent false ripples during scroll deceleration (#4911) - #5133
Open
Priyanshu0007 wants to merge 1 commit into
Open
Priyanshu0007 wants to merge 1 commit into
Priyanshu0007 wants to merge 1 commit into
Conversation
|
Found potential problems with the pull request:
|
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.
Motivation
When tapping or touching an active Button or TouchableRipple inside a decelerating scroll view (or during quick list fling/scroll cancellation touches), the native button immediately triggers an ink ripple animation. However, when the parent
ScrollViewdetects scrolling motion, it steals the touch gesture (cancelling the press andonPress). The button is never activated, leaving the user with false visual feedback.This PR addresses the issue by:
unstable_pressDelay?: numberonButtonandTouchableRippleprops to forward to React Native's underlyingPressable.ripplePressDelay?: numberconfiguration viaSettingsContext(PaperProvider), allowing apps to configure a global press delay (e.g. 50-100ms) across all paper ripple surfaces without having to pass the prop to every component manually.Related issue
Fixes #4911
Test plan
Automated Tests:
Button.test.tsxverifyingunstable_pressDelaytriggersonPresscorrectly.TouchableRipple.test.tsxverifying bothunstable_pressDelayprop andripplePressDelayfromSettingsContext.yarn test,yarn lint,yarn typecheck).Manual Verification (Android):
<ScrollView>.<PaperProvider settings={{ ripplePressDelay: 80 }}>or addunstable_pressDelay={80}to<Button>.onPresstrigger as expected.