Skip to content

Commit 0a5bf33

Browse files
j-piaseckifacebook-github-bot
authored andcommitted
Override shouldDelayChildPressedState in Android containers
Summary: Changelog: [Android][Fixed] Prevent React Native containers from delaying native touches [`shouldDelayChildPressedState`](https://developer.android.com/reference/android/view/ViewGroup#shouldDelayChildPressedState%28%29) returns `true` for compatibility reasons and non-scrollable containers should override it and return `false` to prevent the press feedback from being delayed. Differential Revision: D108003374
1 parent 40c90ad commit 0a5bf33

5 files changed

Lines changed: 10 additions & 0 deletions

File tree

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5403,6 +5403,7 @@ public final class com/facebook/react/views/modal/ReactModalHostView : android/v
54035403
public final fun setStateWrapper (Lcom/facebook/react/uimanager/StateWrapper;)V
54045404
public final fun setStatusBarTranslucent (Z)V
54055405
public final fun setTransparent (Z)V
5406+
public fun shouldDelayChildPressedState ()Z
54065407
public final fun showOrUpdate ()V
54075408
}
54085409

@@ -6445,6 +6446,7 @@ public class com/facebook/react/views/view/ReactViewGroup : android/view/ViewGro
64456446
public fun setPointerEvents (Lcom/facebook/react/uimanager/PointerEvents;)V
64466447
public fun setRemoveClippedSubviews (Z)V
64476448
public final fun setTranslucentBackgroundDrawable (Landroid/graphics/drawable/Drawable;)V
6449+
public fun shouldDelayChildPressedState ()Z
64486450
public fun updateClippingRect ()V
64496451
public fun updateClippingRect (Ljava/util/Set;)V
64506452
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ public class ReactModalHostView(context: ThemedReactContext) :
134134
dialogRootViewGroup.dispatchProvideStructure(structure)
135135
}
136136

137+
override fun shouldDelayChildPressedState(): Boolean = false
138+
137139
protected override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
138140
// Do nothing as we are laid out by UIManager
139141
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/safeareaview/ReactSafeAreaView.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ internal class ReactSafeAreaView(val reactContext: ThemedReactContext) : ViewGro
3939

4040
override fun onLayout(p0: Boolean, p1: Int, p2: Int, p3: Int, p4: Int): Unit = Unit
4141

42+
override fun shouldDelayChildPressedState(): Boolean = false
43+
4244
@Suppress("DEPRECATION")
4345
@UiThread
4446
private fun updateState(insets: Insets) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/text/PreparedLayoutTextView.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,8 @@ internal class PreparedLayoutTextView(context: Context) : ViewGroup(context), Re
402402
}
403403
}
404404

405+
override fun shouldDelayChildPressedState(): Boolean = false
406+
405407
public override fun dispatchHoverEvent(event: MotionEvent): Boolean =
406408
super.dispatchHoverEvent(event)
407409

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,8 @@ public open class ReactViewGroup public constructor(context: Context?) :
650650
}
651651
}
652652

653+
override fun shouldDelayChildPressedState(): Boolean = false
654+
653655
override fun dispatchSetPressed(pressed: Boolean) {
654656
// Prevents the ViewGroup from dispatching the pressed state
655657
// to it's children.

0 commit comments

Comments
 (0)