Skip to content

Commit f53f3d3

Browse files
committed
Fix crash when accessibilityRole="tabbar" is used on Android
tabbar is part of the public AccessibilityRole union in both Flow and TypeScript with nothing marking it iOS-only, but the Android enum had no TABBAR entry, so fromValue() threw during createViewInstance and the app crashed on mount. Add TABBAR to the enum and map it to android.view.View, alongside TAB and TABLIST which also have no dedicated Android widget. Fixes #57890
1 parent 2ab916f commit f53f3d3

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ public open class ReactAccessibilityDelegate( // The View this delegate is attac
437437
SPINBUTTON,
438438
SWITCH,
439439
TAB,
440+
TABBAR,
440441
TABLIST,
441442
TIMER,
442443
LIST,
@@ -491,6 +492,7 @@ public open class ReactAccessibilityDelegate( // The View this delegate is attac
491492
RADIOGROUP,
492493
SCROLLBAR,
493494
TAB,
495+
TABBAR,
494496
TABLIST,
495497
TIMER,
496498
TOOLBAR -> "android.view.View"

packages/react-native/ReactAndroid/src/test/java/com/facebook/react/uimanager/ReactAccessibilityDelegateTest.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,15 @@ class ReactAccessibilityDelegateTest {
347347
assertThat(view.getTag(R.id.accessibility_state_expanded)).isEqualTo(true)
348348
}
349349

350+
@Test
351+
fun testAccessibilityRole_fromValue_tabbar_resolvesInsteadOfThrowing() {
352+
val role = ReactAccessibilityDelegate.AccessibilityRole.fromValue("tabbar")
353+
354+
assertThat(role).isEqualTo(ReactAccessibilityDelegate.AccessibilityRole.TABBAR)
355+
assertThat(ReactAccessibilityDelegate.AccessibilityRole.getValue(role))
356+
.isEqualTo("android.view.View")
357+
}
358+
350359
@Test
351360
fun testPerformAccessibilityAction_collapseAction_fromAccessibilityActions() {
352361
val accessibilityActions = JavaOnlyArray()

0 commit comments

Comments
 (0)