Repository navigation
fix(button): apply accessibility props and loading to the pressable - #5225
Open
datsiuk-ck wants to merge 1 commit into
Open
datsiuk-ck wants to merge 1 commit into
datsiuk-ck wants to merge 1 commit into
Conversation
|
Found potential problems with the pull request:
|
This branch has not been deployed
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.
Motivation
Buttonpasses every prop it doesn't name to its outerSurface, soaccessibilityLabel,accessibilityState,accessibilityRoleand thearia-*states never reached the Pressable that screen readers treat as the button. A loading button wasn't busy either: its spinner was a separate busy progress element. With the issue's repro, the button was read as "Save", with no expanded or busy state.This PR:
accessibilityLabel,accessibilityState,accessibilityRole,aria-busy,aria-checkedandaria-selectedto the pressable, as fix(button): forward expanded state to the interactive control #5148 did foraria-expanded. State fields go out asaria-*props, since react-native-web ignoresaccessibilityState.ActivityIndicatorfrom assistive technology (aria-hidden).accessibilityRolereplace the defaultrole="button", soaccessibilityRole="link"gives one link instead of a link around a button.<Button loading>Uploading</Button>would otherwise be read as "busy. Button".Buttonfrom the migration guide's list of components that pass these props to their outer container.Related issue
Closes #5216. Unlike #5217, this also keeps the name of a loading button without a label on Android, and covers the
aria-*states andaccessibilityRole.Screenshots / Videos
loading, no labelbutton "Save"insidegeneric "Save draft", plus a progressbarbutton "Save draft", expanded: false, busyTest plan
Checked with
mainand this branch side by side (Expo 58, React Native 0.88.1): Android emulator with TalkBack, iOS simulator with Accessibility Inspector, Chrome.<Button accessibilityLabel="Save draft" accessibilityState={{ expanded: false }} loading>Save</Button>: one item on every platform, named "Save draft", busy (and collapsed on Android and web). TalkBack swipes past it with no progress bar item.<Button loading>Uploading {3} files</Button>on Android: "Uploading 3 files, busy. Button".accessibilityRole="link": one link (TalkBack "Open docs. Link").aria-busy/aria-selected: on the button itself ("Syncing, busy", "selected. Inbox").disabled, toggle, icon and plain buttons: unchanged.Unit tests cover each case.
Known limitation: on Android, a loading button whose content isn't plain text (e.g.
<Trans>) keeps its name but isn't announced as busy.