Skip to content

Declare tappable views as accessibility buttons#614

Open
RoyalPineapple wants to merge 6 commits intomainfrom
RoyalPineapple/tappable-button
Open

Declare tappable views as accessibility buttons#614
RoyalPineapple wants to merge 6 commits intomainfrom
RoyalPineapple/tappable-button

Conversation

@RoyalPineapple
Copy link
Copy Markdown
Collaborator

🤖 Summary:

  • Mark TappableView as an accessibility element with the .button trait.
  • Add tests for the backing view trait and for button trait inheritance through accessibilityCombine.

Verification:

  • xcodebuild build -scheme BlueprintUICommonControls -destination 'platform=iOS Simulator,id=EF731F66-6F9B-40A7-9F42-0C6CF3CBEFAB'

@RoyalPineapple RoyalPineapple requested a review from a team as a code owner May 5, 2026 11:57
RoyalPineapple and others added 5 commits May 5, 2026 14:40
`accessibilityTraits(add:)` takes `Set<Accessibility.Trait>`, so a single
trait must be passed as a set literal (`[.button]`).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The wrapped element now carries the .button trait via
`accessibilityTraits(add: [.button])`, which produces a CombinableView
that combines the inner accessibility label. Setting
`isAccessibilityElement` and `accessibilityTraits` directly on
TappableView is redundant and would actually shadow the wrapped
element's accessibility label.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…tions

These tests asserted that TappableView itself was the accessibility
element with the .button trait. That behavior was removed along with
the redundant view-level mutations, so the tests no longer reflect
how Tappable exposes accessibility.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Verifies that .tappable produces an accessibility element exposing the
.button trait and the wrapped element's label, both directly and when
further wrapped in .accessibilityCombine().

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The single remaining test already verifies that the wrapped Label's
accessibilityLabel is picked up alongside the .button trait, which
is the property accessibilityCombine would have asserted as well.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

public init(onTap: @escaping () -> Void, wrapping element: Element) {
wrappedElement = element
wrappedElement = element.accessibilityTraits(add: [.button])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should do be doing this conditionally? For example if the element already has a .link trait does it make sense to also apply .button?


public init(onTap: @escaping () -> Void, wrapping element: Element) {
wrappedElement = element
wrappedElement = element.accessibilityTraits(add: [.button])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does the onTap need to be wired up to actually be activated by voiceover?

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.

2 participants