Skip to content

[Proposal] Delay Pressable press-in inside ScrollView - #60331

Merged
javache merged 1 commit into
react:mainfrom
zoontek:pressable-delay-press-in-scroll-view
Dec 3, 2026
Merged

javache merged 1 commit into
react:mainfrom
zoontek:pressable-delay-press-in-scroll-view

Conversation

@zoontek

@zoontek zoontek commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Summary:

This is a proposal. Feel free to close it if this is not the direction you want for Pressable.

Pressable calls onPressIn as soon as the finger touches it. When the touch turns into a scroll, the press feedback flashes on every item the finger lands on. It creates this kind of issue (compared to RNGH Touchable).

This adds a JS-only flag, delayPressInInScrollView. When it is on, a Pressable inside a ScrollView waits 130 ms before onPressIn (the same delay as the highlight delay of the legacy Touchable mixin). If the scroll view takes the touch during the delay, no press callback fires. An explicit unstable_pressDelay still wins.

Changelog:

[GENERAL] [ADDED] - Add delayPressInInScrollView feature flag to delay Pressable press-in inside a ScrollView

Test Plan:

To try it, turn on the flag in the entry file:

import * as ReactNativeFeatureFlags from 'react-native/src/private/featureflags/ReactNativeFeatureFlags';

ReactNativeFeatureFlags.override({delayPressInInScrollView: () => true});

Then start a scroll on a tile. The tile no longer turns red:

<FlatList
  data={Array.from({length: 40}, (_, i) => i)}
  renderItem={({item}) => (
    <Pressable
      onPress={() => console.log('press', item)}
      style={({pressed}) => ({
        height: 160,
        margin: 4,
        backgroundColor: pressed ? 'red' : '#cfd8e3',
      })}
    />
  )}
/>

On an Android emulator (RN 0.88.1 with the same patch), fast and slow scrolls no longer fire onPressIn. Taps and long holds still work. This matches Touchable from react-native-gesture-handler 3.4.

@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 Nov 27, 2026

@janicduplessis janicduplessis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, I guess the main benifit vs using the pressDelay prop directly is that it will only happen when inside a scrollview.

Not sure how I feel about it being a feature flag as I wonder how much it will be used, but if plan is to turn it on by default after a release or 2 I think it's ok.

@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Nov 27, 2026
@zoontek

zoontek commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

@janicduplessis Yes, the plan would be to enable it by default and remove the flag at some point.

We can of course discuss about having it enabled by default, with the flag as an opt-out. Or even no flag at all. I can update the PR after feedbacks.

isInScrollView &&
ReactNativeFeatureFlags.delayPressInInScrollView()
? SCROLL_VIEW_PRESS_DELAY_MS
: unstable_pressDelay;

@intergalacticspacehighway intergalacticspacehighway Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a6395d5406a

This is intended to be used to experiment with adding a delay for when onPressIn fires. The intended purpose of this delay is to prevent Pressable elements from activating (i.e. onPressIn firing) if a touch gesture is immediately canceled by an enclosing native component (e.g. ScrollView).

The fix mechanism existed in RN since 2020 😅. wdyt of keeping the feature flag default to true (opt-out instead of opt-in)? (one can also pass unstable_pressDelay 0 to opt-out)

@zoontek zoontek Nov 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@intergalacticspacehighway I'd rather too! I will make the switch on monday.

Do you think a flag is necessary? Or we can just recommend setting unstable_pressDelay to 0 on all ScrollView?

We can even imagine removing the unstable_ prefix in a following PR, if it's that old (as delayPressIn)

@javache javache left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an ok workaround - the real fix would require us (like rn-gesture-handler?) to declare these gesture handler relations up front so we can run / evaluate them synchronously.

Comment on lines +255 to +260
const delayPressIn =
unstable_pressDelay == null &&
isInScrollView &&
ReactNativeFeatureFlags.delayPressInInScrollView()
? SCROLL_VIEW_PRESS_DELAY_MS
: unstable_pressDelay;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems reasonable to me - I think we can also push to deprecate/remove unstable_pressDelay after this, since this doing it conditionally based on a containing scrollview is better.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javache I agree, we should map it as delayPressIn prop. I can open the PR once this one is merged.

const isInScrollView = useContext(ScrollViewContext) != null;

const delayPressIn =
unstable_pressDelay == null &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's document that you can opt-out of this behaviour by setting unstable_pressDelay={0}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @Simek

@javache

javache commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Can you rebase past the ReactNativeFeatureFlags conflicts?

# Conflicts:
#	packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js
@zoontek
zoontek force-pushed the pressable-delay-press-in-scroll-view branch from 4f68877 to e9baaaa Compare December 2, 2026 15:10
@zoontek

zoontek commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

@javache Done ✅

@github-actions github-actions Bot added the Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. label Dec 2, 2026
@meta-codesync

meta-codesync Bot commented Dec 3, 2026

Copy link
Copy Markdown

@javache has imported this pull request. If you are a Meta employee, you can view this in D135928009.

@javache
javache merged commit 429d73e into react:main Dec 3, 2026
101 checks passed
@zoontek
zoontek deleted the pressable-delay-press-in-scroll-view branch December 3, 2026 11:36
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. Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants