Skip to content

fix(button): apply accessibility props and loading to the pressable - #5225

Open
datsiuk-ck wants to merge 2 commits into
callstack:mainfrom
datsiuk-ck:fix/button-a11y-props
Open

datsiuk-ck wants to merge 2 commits into
callstack:mainfrom
datsiuk-ck:fix/button-a11y-props

Conversation

@datsiuk-ck

@datsiuk-ck datsiuk-ck commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Button passed every prop it doesn't name to its outer Surface, so accessibilityLabel, accessibilityState and the aria-* states missed the pressable, and a loading button wasn't busy (its spinner was a separate progress item). They now reach the pressable, and the spinner is hidden from assistive technology.

On Android, React Native writes busy into the content description TalkBack reads, so a plain-text button is labelled by its text there and busy is always true/false; otherwise TalkBack reads "busy" instead of the text, and keeps reading it after loading ends.

Related issue

Closes #5216

Test plan

main vs this branch, TalkBack, iOS Accessibility Inspector, Chrome: the issue's button is one item, "Save draft", busy; loading on/off reads "Uploading, busy" then "Upload"; unchanged buttons read the same. Unit tests cover each case.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Found potential problems with the pull request:

  • Screenshot or video evidence is missing. Make sure to include one if it affects the UI.

@Doberjohn

Copy link
Copy Markdown
Collaborator

/review

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 59f05a2

1 finding(s): 1 minor.

🟡 Minor (1)

Where Finding
docs/6.x/docs/guides/migration.md:310 Migration guide still says accessibilityRole of Button became role
Not in the reviewers' prompt (1 file)
  • src/components/__tests__/__snapshots__/Button.test.tsx.snap: generated or a lockfile, so its lines were left out

3 findings below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (677ab9f2b2cf).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on 59f05a2. The verdict and the full list are in the summary comment.

Comment thread docs/6.x/docs/guides/migration.md Resolved
@Doberjohn

Copy link
Copy Markdown
Collaborator

Thanks, the fix works on all three platforms. Three things before merging:

  1. Android: after loading turns off, TalkBack still says "busy" (and an unlabelled button loses its text). React Native only rebuilds the description when busy is set, so it needs false, not undefined. This fixed it for me:

    -    busy === true &&
    ...
    -    needsAndroidBusyLabel && childrenText === undefined ? undefined : busy;
    +    Platform.OS === 'android'
    +      ? needsAndroidBusyLabel && childrenText === undefined ? false : busy === true
    +      : busy;

    A rerender test with loading={false} would keep it fixed.

  2. Web: a Button with accessibilityRole="link" no longer activates on Enter or Space (it did on main). Could you keep it keyboard-activatable, or tell me if you'd rather handle it separately?

  3. The description is about 4200 characters; please trim it under 1000.

@datsiuk-ck

Copy link
Copy Markdown
Contributor Author
  1. Applied your fix, thanks.
  2. Thanks! I’ve taken accessibilityRole out of this PR, so a Button with accessibilityRole="link" behaves as on main again, keyboard included. The keyboard problem also affects <Button role="link"> on main (react-native-web doesn’t press role="link" elements itself), so I think it's better to handle the link role in a separate PR.
  3. Done.

@datsiuk-ck
datsiuk-ck requested a review from Doberjohn November 20, 2026 12:59

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Button: accessibilityLabel, accessibilityState and loading state don't reach the pressable

2 participants