Add accessibility modifiers#59
Merged
Merged
Conversation
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.
.accessibilityLabel,.accessibilityValue,.accessibilityHidden,.accessibilityAddTraits, and.accessibilityIdentifier— the last Tier-A system, and the one that was blocking shipping a real app.Shape
These describe a view rather than changing it, so all of them fold into Compose semantics and nothing else: label →
contentDescription, value →stateDescription, traits →Role.Button/Role.Image/heading()/selected, identifier →testTag. Hiding usesclearAndSetSemantics, which drops the node and its subtree — the right meaning for a container.Verified against the real accessibility tree
Accessibility is unusually verifiable here: uiautomator reads the accessibility tree directly, so this is ground truth rather than pixel inspection.
Text("7").accessibilityLabel("Unread messages")reportscontent-desc="Unread messages". The label replaces the underlying text, which is the whole point..isButtonchanges the node's class fromandroid.widget.TextViewtoandroid.widget.Button; a neighbouring untaggedTextstays aTextViewas a control.swift testcovers emission for all of them (101 passing), including thataccessibilityHidden(false)still emits — it has to be able to override an inherited hide — and that adding a description leaves the node type, children, and text untouched.What I could not verify, and why
accessibilityValue(stateDescription), the.isHeadertrait, and.accessibilityIdentifier(testTag) are all applied, but uiautomator's XML has no attribute for any of them — its node schema is a fixed set that excludes state description, heading, and test tags (the last needstestTagsAsResourceId). TalkBack and Compose UI tests read them; this harness can't. I'd rather flag that than imply I confirmed it.Deliberately not included
.accessibilityElement(children:). I implemented it, andsemantics(mergeDescendants = true)did not merge the children — the two texts stayed separate nodes in the tree. Rather than ship a modifier that silently does nothing, I removed it. (That failure mode is exactly the unread-detentsbug from #58, so shipping it would have been the same mistake.).accessibilityHintis also absent: Compose semantics has no hint equivalent, and faking it by appending to the label would corrupt what gets announced.