Skip to content

[Android] Don't delay child pressed state in buttons - #4296

Merged
j-piasecki merged 1 commit into
mainfrom
@jpiasecki/dont-delay-child-pressed-state-buttons
Jul 6, 2026
Merged

j-piasecki merged 1 commit into
mainfrom
@jpiasecki/dont-delay-child-pressed-state-buttons

Conversation

@j-piasecki

Copy link
Copy Markdown
Member

Description

react/react-native#57127 added an override for shouldDelayChildPressedState in React Native containers to prevent them from delaying the pressed state in children. All components extending them will get this for free, but our button implementation doesn't extend ReactViewGroup but ViewGroup.

This PR adds override for shouldDelayChildPressedState in RNGestureHandlerButtonViewManager.

Copilot AI review requested due to automatic review settings July 6, 2026 09:11

Copilot AI 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.

Pull request overview

This PR updates the Android ButtonViewGroup used by RNGestureHandlerButtonViewManager to avoid delaying pressed-state propagation to child views, matching the behavior React Native added for ReactViewGroup-based containers (which this implementation does not extend).

Changes:

  • Override shouldDelayChildPressedState() in ButtonViewGroup to always return false, so child pressed state is applied immediately.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@j-piasecki
j-piasecki merged commit 12cb193 into main Jul 6, 2026
4 checks passed
@j-piasecki
j-piasecki deleted the @jpiasecki/dont-delay-child-pressed-state-buttons branch July 6, 2026 13:09
m-bert pushed a commit that referenced this pull request Sep 11, 2026
react/react-native#57127 added an override for
`shouldDelayChildPressedState` in React Native containers to prevent
them from delaying the pressed state in children. All components
extending them will get this for free, but our button implementation
doesn't extend `ReactViewGroup` but `ViewGroup`.

This PR adds override for `shouldDelayChildPressedState` in
`RNGestureHandlerButtonViewManager`.
j-piasecki added a commit to software-mansion/react-native-screens that referenced this pull request Oct 2, 2026
…pressed state

[`shouldDelayChildPressedState`](https://developer.android.com/reference/android/view/ViewGroup#shouldDelayChildPressedState%28%29) returns `true` by default and should be overridden by non-scrolling containers to return false. Having it return `true` causes a slight delay before showing interaction feedback on native buttons.

Related: react/react-native#57127, software-mansion/react-native-gesture-handler#4296

Adds `shouldDelayChildPressedState` override to the legacy (`legacy/`) container views and to `TabsScreen`. `ScreensCoordinatorLayout` keeps delaying the pressed state when presented as a form sheet, since the sheet is draggable. These changes are kept separate so they can be cherry-picked to the legacy branch.
j-piasecki added a commit to software-mansion/react-native-screens that referenced this pull request Oct 2, 2026
## Description

[`shouldDelayChildPressedState`](https://developer.android.com/reference/android/view/ViewGroup#shouldDelayChildPressedState%28%29) returns `true` by default and should be overridden by non-scrolling containers to return false. Having it return `true` causes a slight delay before showing interaction feedback on native buttons.

Related: react/react-native#57127, software-mansion/react-native-gesture-handler#4296

I'm not sure whether the decisions behind when to simply return `false` and when to make it conditional make sense. Generally, when something is scrollable/draggable, it should return true. Let me know if I missed anything.

## Changes

Adds `shouldDelayChildPressedState` override to container views.

## Before & after - visual documentation

Video at 1/4 speed

https://github.com/user-attachments/assets/d6021082-a96d-4a37-8c9b-832e33393232

## Test plan

<details>
<summary>Tested using Gesture Handler 3 `Touchable`</summary>

```jsx
import React from 'react';
import { StatusBar, StyleSheet, Text, View } from 'react-native';
import {
  GestureHandlerRootView,
  Touchable,
} from 'react-native-gesture-handler';
import {
  Screen,
  ScreenStack,
  ScreenStackHeaderConfig,
} from 'react-native-screens';

export default function TouchablePressedState() {
  return (
    <GestureHandlerRootView style={styles.root}>
      <StatusBar hidden />
      <ScreenStack style={styles.root}>
        <Screen activityState={2} stackAnimation="none" style={styles.root}>
          <ScreenStackHeaderConfig hidden />
          <View style={styles.content}>
            <Text style={styles.eyebrow}>ANDROID · NATIVE STACK</Text>
            <Text style={styles.title}>Pressed state timing</Text>
            <Text style={styles.description}>
              Hold the button. The Android touch circle marks contact; blue
              marks the native pressed feedback.
            </Text>
            <Touchable
              testID="pressed-state-touchable"
              accessibilityLabel="Hold to show pressed feedback"
              animationDuration={0}
              underlayColor="#2563eb"
              activeUnderlayOpacity={1}
              style={styles.button}
              onPress={() => {}}>
              <Text style={styles.buttonText}>PRESS AND HOLD</Text>
            </Touchable>
            <Text style={styles.detail}>RNGH 3 Touchable</Text>
            <Text style={styles.code}>animationDuration={0}</Text>
            <Text style={styles.footnote}>
              Same screen and held gesture in both builds. Only the Screens
              native overrides change.
            </Text>
          </View>
        </Screen>
      </ScreenStack>
    </GestureHandlerRootView>
  );
}

const styles = StyleSheet.create({
  root: { flex: 1, backgroundColor: '#0f172a' },
  content: { flex: 1, justifyContent: 'center', padding: 28 },
  eyebrow: {
    color: '#94a3b8',
    fontSize: 12,
    fontWeight: '700',
    letterSpacing: 2,
  },
  title: { color: '#f8fafc', fontSize: 30, fontWeight: '700', marginTop: 12 },
  description: {
    color: '#cbd5e1',
    fontSize: 16,
    lineHeight: 24,
    marginTop: 16,
  },
  button: {
    height: 148,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#334155',
    borderRadius: 18,
    marginTop: 36,
    marginBottom: 28,
  },
  buttonText: { color: '#ffffff', fontSize: 20, fontWeight: '700' },
  detail: { color: '#cbd5e1', fontSize: 15 },
  code: {
    color: '#93c5fd',
    fontFamily: 'monospace',
    fontSize: 15,
    marginTop: 6,
  },
  footnote: { color: '#94a3b8', fontSize: 13, lineHeight: 20, marginTop: 28 },
});

```

</details>

## Checklist

- [x] Included code example that can be used to test this change.
- [x] For visual changes, included screenshots / GIFs / recordings documenting the change.
- [x] For API changes, updated relevant public types.
- [x] Ensured that CI passes
kkafar pushed a commit to software-mansion/react-native-screens that referenced this pull request Oct 9, 2026
…pressed state (#4771)

[`shouldDelayChildPressedState`](https://developer.android.com/reference/android/view/ViewGroup#shouldDelayChildPressedState%28%29)
returns `true` by default and should be overridden by non-scrolling
containers to return false. Having it return `true` causes a slight
delay before showing interaction feedback on native buttons.

Related: react/react-native#57127,
software-mansion/react-native-gesture-handler#4296

Adds `shouldDelayChildPressedState` override to the legacy (`legacy/`)
container views and to `TabsScreen`. `ScreensCoordinatorLayout` keeps
delaying the pressed state when presented as a form sheet, since the
sheet is draggable. These changes are kept separate so they can be
cherry-picked to the legacy branch.
kkafar pushed a commit to software-mansion/react-native-screens that referenced this pull request Oct 9, 2026
## Description

[`shouldDelayChildPressedState`](https://developer.android.com/reference/android/view/ViewGroup#shouldDelayChildPressedState%28%29) returns `true` by default and should be overridden by non-scrolling containers to return false. Having it return `true` causes a slight delay before showing interaction feedback on native buttons.

Related: react/react-native#57127, software-mansion/react-native-gesture-handler#4296

I'm not sure whether the decisions behind when to simply return `false` and when to make it conditional make sense. Generally, when something is scrollable/draggable, it should return true. Let me know if I missed anything.

## Changes

Adds `shouldDelayChildPressedState` override to container views.

## Before & after - visual documentation

Video at 1/4 speed

https://github.com/user-attachments/assets/d6021082-a96d-4a37-8c9b-832e33393232

## Test plan

<details>
<summary>Tested using Gesture Handler 3 `Touchable`</summary>

```jsx
import React from 'react';
import { StatusBar, StyleSheet, Text, View } from 'react-native';
import {
  GestureHandlerRootView,
  Touchable,
} from 'react-native-gesture-handler';
import {
  Screen,
  ScreenStack,
  ScreenStackHeaderConfig,
} from 'react-native-screens';

export default function TouchablePressedState() {
  return (
    <GestureHandlerRootView style={styles.root}>
      <StatusBar hidden />
      <ScreenStack style={styles.root}>
        <Screen activityState={2} stackAnimation="none" style={styles.root}>
          <ScreenStackHeaderConfig hidden />
          <View style={styles.content}>
            <Text style={styles.eyebrow}>ANDROID · NATIVE STACK</Text>
            <Text style={styles.title}>Pressed state timing</Text>
            <Text style={styles.description}>
              Hold the button. The Android touch circle marks contact; blue
              marks the native pressed feedback.
            </Text>
            <Touchable
              testID="pressed-state-touchable"
              accessibilityLabel="Hold to show pressed feedback"
              animationDuration={0}
              underlayColor="#2563eb"
              activeUnderlayOpacity={1}
              style={styles.button}
              onPress={() => {}}>
              <Text style={styles.buttonText}>PRESS AND HOLD</Text>
            </Touchable>
            <Text style={styles.detail}>RNGH 3 Touchable</Text>
            <Text style={styles.code}>animationDuration={0}</Text>
            <Text style={styles.footnote}>
              Same screen and held gesture in both builds. Only the Screens
              native overrides change.
            </Text>
          </View>
        </Screen>
      </ScreenStack>
    </GestureHandlerRootView>
  );
}

const styles = StyleSheet.create({
  root: { flex: 1, backgroundColor: '#0f172a' },
  content: { flex: 1, justifyContent: 'center', padding: 28 },
  eyebrow: {
    color: '#94a3b8',
    fontSize: 12,
    fontWeight: '700',
    letterSpacing: 2,
  },
  title: { color: '#f8fafc', fontSize: 30, fontWeight: '700', marginTop: 12 },
  description: {
    color: '#cbd5e1',
    fontSize: 16,
    lineHeight: 24,
    marginTop: 16,
  },
  button: {
    height: 148,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#334155',
    borderRadius: 18,
    marginTop: 36,
    marginBottom: 28,
  },
  buttonText: { color: '#ffffff', fontSize: 20, fontWeight: '700' },
  detail: { color: '#cbd5e1', fontSize: 15 },
  code: {
    color: '#93c5fd',
    fontFamily: 'monospace',
    fontSize: 15,
    marginTop: 6,
  },
  footnote: { color: '#94a3b8', fontSize: 13, lineHeight: 20, marginTop: 28 },
});

```

</details>

## Checklist

- [x] Included code example that can be used to test this change.
- [x] For visual changes, included screenshots / GIFs / recordings documenting the change.
- [x] For API changes, updated relevant public types.
- [x] Ensured that CI passes
t0maboro added a commit to software-mansion/react-native-screens that referenced this pull request Oct 12, 2026
…pressed state (#4771) (#4864)

[`shouldDelayChildPressedState`](https://developer.android.com/reference/android/view/ViewGroup#shouldDelayChildPressedState%28%29)
returns `true` by default and should be overridden by non-scrolling
containers to return false. Having it return `true` causes a slight
delay before showing interaction feedback on native buttons.

Related: react/react-native#57127,

software-mansion/react-native-gesture-handler#4296

Adds `shouldDelayChildPressedState` override to the legacy (`legacy/`)
container views and to `TabsScreen`. `ScreensCoordinatorLayout` keeps
delaying the pressed state when presented as a form sheet, since the
sheet is draggable. These changes are kept separate so they can be
cherry-picked to the legacy branch.

(cherry picked from commit cc069e6)

Co-authored-by: Jakub Piasecki <jakub.piasecki@swmansion.com>
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.

3 participants