Skip to content

Add accessibilityLabel override to AttributedLabel#625

Draft
RoyalPineapple wants to merge 2 commits into
mainfrom
RoyalPineapple/create-pr
Draft

Add accessibilityLabel override to AttributedLabel#625
RoyalPineapple wants to merge 2 commits into
mainfrom
RoyalPineapple/create-pr

Conversation

@RoyalPineapple

Copy link
Copy Markdown
Collaborator

Adds an optional accessibilityLabel: String? to the AttributedLabel model so consumers can override or suppress the label that is otherwise derived automatically from the displayed text. nil (the default) preserves today's text-derived behavior, a non-nil value overrides it, and "" suppresses the spoken label entirely — useful when the text is surfaced through accessibilityValue/accessibilityHint and the label is merged into a combined accessibility element, so the content isn't announced twice. The change is purely additive: no existing call sites change. Internally, the expensive text-derived label is cached behind the existing text-change guard in LabelView while the override is applied on every update, so an override change takes effect even when the text is unchanged, with no perf regression. Adds tests covering the default/override/suppression cases, application without a text change, and suppression flowing through AccessibilityComposition.

RoyalPineapple and others added 2 commits June 29, 2026 16:52
Adds an optional `accessibilityLabel: String?` to the AttributedLabel
model: `nil` (default) derives the label from the displayed text as
before, a non-nil value overrides it, and `""` suppresses the spoken
label entirely (useful when content is surfaced via accessibilityValue
and the label is merged into a combined accessibility element).

The expensive text-derived label is now cached behind the existing
text-change guard in LabelView, while the override is applied on every
update so a change takes effect even when the text is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant