Skip to content

SwitchView: check the VoiceOver traits (only .isToggle, no button trait) #27

Open

Description

@romchornyi

Summary

SwitchView (Components/Switch/SwitchView.swift) is an onTapGesture shape, not a Button or Toggle. Its only accessibility trait is .isToggle, and it sets an accessibilityValue of "On"/"Off" by hand.

This was found while reviewing #15 and is not a regression. iOS 17+ already ran this path, and #15 only removed the .isButton fallback for iOS 14–16.

Risk (not verified on a device)

  • The element has no button trait, so VoiceOver may not give the activation hint ("double-tap to toggle").
  • The state may be announced twice, once from accessibilityValue and once from the toggle trait.

Proposed fix

  1. Run VoiceOver against a native Toggle and SwitchView side by side.
  2. Then pick one:
    • accessibilityAddTraits([.isButton, .isToggle]), keeping or dropping the manual value depending on what VoiceOver reads;
    • or build the switch as a Toggle with a custom ToggleStyle, so it gets the system semantics for free.

Related: the accessibility audit of the shared components (ticket 32072).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions