You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix keyboard navigation for FlatList with removeClippedSubviews enabled (#50105)
Summary:
When using `ReactScrollView` or `ReactHorizontalScrollView` Views with `removeClippedSubviews` keyboard navigation didn't work.
This is because keyboard navigation relies on Android's View hierarchy to find the next focusable element. With `removeClippedSubviews` the next View might've been removed from the hierarchy.
With this change we delegate the job of figuring out the next focusable element to the Shadow Tree, which will always contain layout information of the next element of the ScrollView.
We then prevent the clipping of the topmost parent of the next focusable view to lay out the entire containing element in case we have some necessary context in the parent
Changelog: [Android][Fixed] - Fix keyboard navigation on lists with `removeClippedSubviews` enabled
Reviewed By: joevilches
Differential Revision: D71324219
Copy file name to clipboardExpand all lines: packages/react-native/ReactAndroid/api/ReactAndroid.api
+10
Original file line number
Diff line number
Diff line change
@@ -2343,6 +2343,8 @@ public class com/facebook/react/fabric/FabricUIManager : com/facebook/react/brid
2343
2343
public fun dispatchCommand (IILcom/facebook/react/bridge/ReadableArray;)V
2344
2344
public fun dispatchCommand (IILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
2345
2345
public fun dispatchCommand (ILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
2346
+
public fun findNextFocusableElement (III)Ljava/lang/Integer;
2347
+
public fun findRelativeTopMostParent (II)Ljava/lang/Integer;
2346
2348
public fun getColor (I[Ljava/lang/String;)I
2347
2349
public fun getEventDispatcher ()Lcom/facebook/react/uimanager/events/EventDispatcher;
2348
2350
public fun getPerformanceCounters ()Ljava/util/Map;
@@ -3982,6 +3984,7 @@ public abstract interface class com/facebook/react/uimanager/ReactClippingViewGr
3982
3984
public abstract fun getRemoveClippedSubviews ()Z
3983
3985
public abstract fun setRemoveClippedSubviews (Z)V
3984
3986
public abstract fun updateClippingRect ()V
3987
+
public abstract fun updateClippingRect (Ljava/util/Set;)V
3985
3988
}
3986
3989
3987
3990
public class com/facebook/react/uimanager/ReactClippingViewGroupHelper {
@@ -5894,6 +5897,7 @@ public class com/facebook/react/views/scroll/ReactHorizontalScrollView : android
5894
5897
public fun executeKeyEvent (Landroid/view/KeyEvent;)Z
5895
5898
public fun flashScrollIndicators ()V
5896
5899
public fun fling (I)V
5900
+
public fun focusSearch (Landroid/view/View;I)Landroid/view/View;
5897
5901
public fun getChildVisibleRect (Landroid/view/View;Landroid/graphics/Rect;Landroid/graphics/Point;)Z
5898
5902
public fun getClippingRect (Landroid/graphics/Rect;)V
5899
5903
public fun getFlingAnimator ()Landroid/animation/ValueAnimator;
@@ -5956,6 +5960,7 @@ public class com/facebook/react/views/scroll/ReactHorizontalScrollView : android
5956
5960
public fun setStateWrapper (Lcom/facebook/react/uimanager/StateWrapper;)V
5957
5961
public fun startFlingAnimator (II)V
5958
5962
public fun updateClippingRect ()V
5963
+
public fun updateClippingRect (Ljava/util/Set;)V
5959
5964
}
5960
5965
5961
5966
public class com/facebook/react/views/scroll/ReactHorizontalScrollViewManager : com/facebook/react/uimanager/ViewGroupManager, com/facebook/react/views/scroll/ReactScrollViewCommandHelper$ScrollCommandHandler {
@@ -6016,6 +6021,7 @@ public class com/facebook/react/views/scroll/ReactScrollView : android/widget/Sc
6016
6021
public fun executeKeyEvent (Landroid/view/KeyEvent;)Z
6017
6022
public fun flashScrollIndicators ()V
6018
6023
public fun fling (I)V
6024
+
public fun focusSearch (Landroid/view/View;I)Landroid/view/View;
6019
6025
public fun getChildVisibleRect (Landroid/view/View;Landroid/graphics/Rect;Landroid/graphics/Point;)Z
6020
6026
public fun getClippingRect (Landroid/graphics/Rect;)V
6021
6027
public fun getFlingAnimator ()Landroid/animation/ValueAnimator;
@@ -6079,6 +6085,7 @@ public class com/facebook/react/views/scroll/ReactScrollView : android/widget/Sc
6079
6085
public fun setStateWrapper (Lcom/facebook/react/uimanager/StateWrapper;)V
6080
6086
public fun startFlingAnimator (II)V
6081
6087
public fun updateClippingRect ()V
6088
+
public fun updateClippingRect (Ljava/util/Set;)V
6082
6089
}
6083
6090
6084
6091
public final class com/facebook/react/views/scroll/ReactScrollViewCommandHelper {
@@ -6136,6 +6143,7 @@ public final class com/facebook/react/views/scroll/ReactScrollViewHelper {
6136
6143
public static final fun emitScrollEvent (Landroid/view/ViewGroup;FF)V
6137
6144
public static final fun emitScrollMomentumBeginEvent (Landroid/view/ViewGroup;II)V
6138
6145
public static final fun emitScrollMomentumEndEvent (Landroid/view/ViewGroup;)V
6146
+
public static final fun findNextFocusableView (Landroid/view/ViewGroup;Landroid/view/View;IZ)Landroid/view/View;
6139
6147
public static final fun forceUpdateState (Landroid/view/ViewGroup;)V
6140
6148
public static final fun getDefaultScrollAnimationDuration (Landroid/content/Context;)I
6141
6149
public static final fun getNextFlingStartValue (Landroid/view/ViewGroup;III)I
@@ -6145,6 +6153,7 @@ public final class com/facebook/react/views/scroll/ReactScrollViewHelper {
6145
6153
public final fun registerFlingAnimator (Landroid/view/ViewGroup;)V
6146
6154
public static final fun removeLayoutChangeListener (Lcom/facebook/react/views/scroll/ReactScrollViewHelper$LayoutChangeListener;)V
6147
6155
public static final fun removeScrollListener (Lcom/facebook/react/views/scroll/ReactScrollViewHelper$ScrollListener;)V
6156
+
public static final fun resolveAbsoluteDirection (IZI)I
6148
6157
public static final fun smoothScrollTo (Landroid/view/ViewGroup;II)V
6149
6158
public static final fun updateFabricScrollState (Landroid/view/ViewGroup;)V
6150
6159
public final fun updateFabricScrollState (Landroid/view/ViewGroup;II)V
@@ -6932,6 +6941,7 @@ public class com/facebook/react/views/view/ReactViewGroup : android/view/ViewGro
6932
6941
public fun setRemoveClippedSubviews (Z)V
6933
6942
public fun setTranslucentBackgroundDrawable (Landroid/graphics/drawable/Drawable;)V
Copy file name to clipboardExpand all lines: packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java
0 commit comments