Skip to content

Report ARIA switch controls as "switch" with a state of on or off#14282

Merged
michaelDCurran merged 10 commits into
masterfrom
i11310
Oct 26, 2022
Merged

Report ARIA switch controls as "switch" with a state of on or off#14282
michaelDCurran merged 10 commits into
masterfrom
i11310

Conversation

@michaelDCurran

@michaelDCurran michaelDCurran commented Oct 23, 2022

Copy link
Copy Markdown
Member

Link to issue number:

Fixes #11310

Summary of the issue:

Currently elements on the web with an ARIA role of "switch" are presented in NVDA as checkboxes.
This is because:

  • There is no switch role in IAccessible2
  • ARIA practices recommend that browsers map the switch role to the toggleButton role in IAccessible2, but there is some confusion around whether the pressed or checked state should be exposed to denote the switch is on.
  • NVDA historically has chosen to deliberately map switches to checkboxes with checked, rather than toggleButton with pressed.
  • ARIA practices state that a switch is the same as a checkbox, just with no indeterminate state.
    There is a lot of pressure from web authors and standards groups for NVDA to specifically report switch controls as having a role of "switch" rather than checkbox, as it is believed this improves communication between blind and sited individuals, as visually the switch control looks like a switch, not a checkbox.

Description of user facing changes

  • switch controls in Firefox, Chrome and Edge, via IAccessible2, are now reported in NVDA as switch controls, rather than checkboxes.
    • They are spoken with a role of "switch" and state of either "on" or "off".
    • In Braille, they are represented with a role of "swtch" and a state braille pattern the same as checked / not checked.

Description of development approach

  • Added a new role of SWITCH
  • Added a new state of ON
  • The negative state of ON is "off".
  • Only a role of switch forces a negative of the ON state. I.e. Switch is the only control that will report as "off" if no ON state exists.
  • The switch role is treeted as having a text presentation type of singleLine, similar to checkbox.
  • for IA2Web NVDAObjects and IAccessible2 virtualBuffers (Chrome, Firefox, Edge), IAccessible2 objects with "switch" in xml-roles:
    • map to an NVDA role of switch
    • pressed and checkable states are discarded
    • the checked state is mapped to the ON state.
      The w3c ARIA examples submodule has also been updated to the latest main commit as the existing commit we were on did not yet have the switch example.

Testing strategy:

Given a switch control such as at https://www.w3.org/WAI/ARIA/apg/example-index/switch/switch

  • Open page in Firefox, Chrome and Edge
  • In browse mode, use the arrow keys to move to the switch control and ensure it announces as a switch E.g. "switch on".
  • In focus mode, tab to the switch control and ensure the control is reported as a switch. E.g. "Notifications switch on"
  • A system test has been added which moves to the switch control in browse mode, toggles the control on and off, and reports the focus.

Known issues with pull request:

For a long time I have been uncomfortable with the word "switch" as it is both a verb and a noun. Also "on" and "off" are not past tense like "checked" or "pressed". Which then means you end up with a phraise like "switch on" which could either be taken as a command (incorrectly) as in "to switch on" or as a statement (correct) "the switch is on". There is not this ambiguity with something like "checkbox checked" or "toggle button pressed".
However, it seems that not many others are bothered by this, so I'm happy to give this ago and see where it lands with our users.

Change log entries:

New features
Changes
Bug fixes

  • ARIA switch controls are now reported as switches in Firefox, Chrome and Edge, rather than checkboxes.
    For Developers

Code Review Checklist:

  • Pull Request description:
    • description is up to date
    • change log entries
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • API is compatible with existing add-ons.
  • Documentation:
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • Security precautions taken.

In speech, negative of On is Off.
In Braille, On and Off are represented the same as checked and not checked respectively.
…ow is mapped to the new Switch NVDA role, and state of On.
@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 59d3b8afa8

@codeofdusk

Copy link
Copy Markdown
Contributor

you end up with a phraise like "switch on" which could either be taken as a command (incorrectly) as in "to switch on" or as a statement (correct) "the switch is on".

Maybe consider "active" and "inactive" in place of "on" and "off"? "switch active" would be less likely considered a command.

@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 54de1673a0

@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 37ebddf1cd

@michaelDCurran michaelDCurran marked this pull request as ready for review October 25, 2022 06:04
@michaelDCurran michaelDCurran requested a review from a team as a code owner October 25, 2022 06:04

@seanbudd seanbudd left a comment

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.

Looks good, only 3 minor linting issues

Comment thread source/braille.py Outdated
Comment thread tests/system/robot/chromeTests.py Outdated
Comment thread source/braille.py Outdated
@michaelDCurran michaelDCurran merged commit bc85f12 into master Oct 26, 2022
@michaelDCurran michaelDCurran deleted the i11310 branch October 26, 2022 06:15
@nvaccessAuto nvaccessAuto added this to the 2023.1 milestone Oct 26, 2022
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.

Button with role="switch" pronounced as checkbox.

5 participants