Add accessibilityLabel override to AttributedLabel#625
Draft
RoyalPineapple wants to merge 2 commits into
Draft
Conversation
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>
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.
Adds an optional
accessibilityLabel: String?to theAttributedLabelmodel 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 throughaccessibilityValue/accessibilityHintand 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 inLabelViewwhile 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 throughAccessibilityComposition.