From 5f27437a841895415a28413cc0b6ef2d9f302d6a Mon Sep 17 00:00:00 2001 From: iray-tno Date: Thu, 24 Sep 2026 02:06:40 +0000 Subject: [PATCH] Fix NPE in ReactScrollViewAccessibilityDelegate for children without accessibilityCollectionItem onInitializeAccessibilityEventInternal read a child's accessibility_collection_item tag with a non-null `as` cast into a nullable variable, even though the code right below handles the null case (checking one nested child, for FlatList without getItemLayout). When a ScrollView has accessibilityCollection set and any direct child of its content view has no accessibilityCollectionItem tag, e.g. a FlatList ListHeaderComponent or ListFooterComponent, the cast throws NullPointerException. With TalkBack on this crashes the app, for example when Fabric removes the accessibility-focused view on navigation and the resulting event reaches the delegate. Use `as?` so the existing null handling runs as intended, matching the other tag reads in this file. Co-Authored-By: Claude Opus 5.5 --- .../react/views/scroll/ReactScrollViewAccessibilityDelegate.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewAccessibilityDelegate.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewAccessibilityDelegate.kt index 741c8845ea40..936a46fd41d9 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewAccessibilityDelegate.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewAccessibilityDelegate.kt @@ -71,7 +71,7 @@ internal class ReactScrollViewAccessibilityDelegate : AccessibilityDelegateCompa return } var accessibilityCollectionItem: ReadableMap? = - nextChild.getTag(R.id.accessibility_collection_item) as ReadableMap + nextChild.getTag(R.id.accessibility_collection_item) as? ReadableMap if (nextChild !is ViewGroup) { return