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:
Pull Request resolved: #50105
Pull Request resolved: #49543
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 {
@@ -5899,6 +5902,7 @@ public class com/facebook/react/views/scroll/ReactHorizontalScrollView : android
5899
5902
public fun executeKeyEvent (Landroid/view/KeyEvent;)Z
5900
5903
public fun flashScrollIndicators ()V
5901
5904
public fun fling (I)V
5905
+
public fun focusSearch (Landroid/view/View;I)Landroid/view/View;
5902
5906
public fun getChildVisibleRect (Landroid/view/View;Landroid/graphics/Rect;Landroid/graphics/Point;)Z
5903
5907
public fun getClippingRect (Landroid/graphics/Rect;)V
5904
5908
public fun getFlingAnimator ()Landroid/animation/ValueAnimator;
@@ -5961,6 +5965,7 @@ public class com/facebook/react/views/scroll/ReactHorizontalScrollView : android
5961
5965
public fun setStateWrapper (Lcom/facebook/react/uimanager/StateWrapper;)V
5962
5966
public fun startFlingAnimator (II)V
5963
5967
public fun updateClippingRect ()V
5968
+
public fun updateClippingRect (Ljava/util/Set;)V
5964
5969
}
5965
5970
5966
5971
public class com/facebook/react/views/scroll/ReactHorizontalScrollViewManager : com/facebook/react/uimanager/ViewGroupManager, com/facebook/react/views/scroll/ReactScrollViewCommandHelper$ScrollCommandHandler {
@@ -6021,6 +6026,7 @@ public class com/facebook/react/views/scroll/ReactScrollView : android/widget/Sc
6021
6026
public fun executeKeyEvent (Landroid/view/KeyEvent;)Z
6022
6027
public fun flashScrollIndicators ()V
6023
6028
public fun fling (I)V
6029
+
public fun focusSearch (Landroid/view/View;I)Landroid/view/View;
6024
6030
public fun getChildVisibleRect (Landroid/view/View;Landroid/graphics/Rect;Landroid/graphics/Point;)Z
6025
6031
public fun getClippingRect (Landroid/graphics/Rect;)V
6026
6032
public fun getFlingAnimator ()Landroid/animation/ValueAnimator;
@@ -6084,6 +6090,7 @@ public class com/facebook/react/views/scroll/ReactScrollView : android/widget/Sc
6084
6090
public fun setStateWrapper (Lcom/facebook/react/uimanager/StateWrapper;)V
6085
6091
public fun startFlingAnimator (II)V
6086
6092
public fun updateClippingRect ()V
6093
+
public fun updateClippingRect (Ljava/util/Set;)V
6087
6094
}
6088
6095
6089
6096
public final class com/facebook/react/views/scroll/ReactScrollViewCommandHelper {
@@ -6141,6 +6148,7 @@ public final class com/facebook/react/views/scroll/ReactScrollViewHelper {
6141
6148
public static final fun emitScrollEvent (Landroid/view/ViewGroup;FF)V
6142
6149
public static final fun emitScrollMomentumBeginEvent (Landroid/view/ViewGroup;II)V
6143
6150
public static final fun emitScrollMomentumEndEvent (Landroid/view/ViewGroup;)V
6151
+
public static final fun findNextFocusableView (Landroid/view/ViewGroup;Landroid/view/View;IZ)Landroid/view/View;
6144
6152
public static final fun forceUpdateState (Landroid/view/ViewGroup;)V
6145
6153
public static final fun getDefaultScrollAnimationDuration (Landroid/content/Context;)I
6146
6154
public static final fun getNextFlingStartValue (Landroid/view/ViewGroup;III)I
@@ -6150,6 +6158,7 @@ public final class com/facebook/react/views/scroll/ReactScrollViewHelper {
6150
6158
public final fun registerFlingAnimator (Landroid/view/ViewGroup;)V
6151
6159
public static final fun removeLayoutChangeListener (Lcom/facebook/react/views/scroll/ReactScrollViewHelper$LayoutChangeListener;)V
6152
6160
public static final fun removeScrollListener (Lcom/facebook/react/views/scroll/ReactScrollViewHelper$ScrollListener;)V
6161
+
public static final fun resolveAbsoluteDirection (IZI)I
6153
6162
public static final fun smoothScrollTo (Landroid/view/ViewGroup;II)V
6154
6163
public static final fun updateFabricScrollState (Landroid/view/ViewGroup;)V
6155
6164
public final fun updateFabricScrollState (Landroid/view/ViewGroup;II)V
@@ -6937,6 +6946,7 @@ public class com/facebook/react/views/view/ReactViewGroup : android/view/ViewGro
6937
6946
public fun setRemoveClippedSubviews (Z)V
6938
6947
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