Fix crash when accessibilityRole="tabbar" is used on Android - #57915
Closed
aravi365 wants to merge 1 commit into
Closed
Fix crash when accessibilityRole="tabbar" is used on Android#57915aravi365 wants to merge 1 commit into
aravi365 wants to merge 1 commit into
Conversation
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 react#57890
|
@Abbondanzo has imported this pull request. If you are a Meta employee, you can view this in D115730694. |
|
@Abbondanzo merged this pull request in a4733b1. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #57890.
tabbaris part of the publicAccessibilityRoleunion in both Flow and TypeScript, with nothing marking it iOS-only, and on iOS it maps toUIAccessibilityTraitTabBar. On Android theAccessibilityRoleenum has noTABBARentry, sofromValue()throwsIllegalArgumentExceptionfromBaseViewManager.setAccessibilityRoleduringcreateViewInstanceand the app crashes on mount. It is the only value in the union Android fails to resolve.This adds
TABBARto the enum and maps it toandroid.view.ViewingetValue, next toTABandTABLIST, which likewise have no dedicated Android widget.getValueis an exhaustivewhenwith noelse, so the second hunk is required for the enum addition to compile.setRolealready has anelsebranch, so noroleDescriptionis set for the new value. That looks right to me, since Android has no tab bar concept to announce, but happy to add a string resource if you'd prefer one.Changelog:
[ANDROID] [FIXED] - Fix crash when
accessibilityRole="tabbar"is used on AndroidTest Plan
Added a unit test to
ReactAccessibilityDelegateTestasserting thatfromValue("tabbar")resolves toTABBARand maps toandroid.view.Viewrather than throwing.Repro from the issue:
Before: crashes on mount on Android with
Invalid accessibility role value: tabbar.After: renders as a plain view, matching iOS, where roles without a UIKit trait fall back rather than raising.
I have not run the Android suite locally, relying on CI for that.