Open Bug 1793880 Opened 2 years ago Updated 2 years ago

`switch` role on checkbox with mixed/indeterminate state reports wrong value

Categories

(Core :: Disability Access APIs, defect)

Firefox 105
defect

Tracking

()

UNCONFIRMED

People

(Reporter: aroselli, Unassigned)

References

(Blocks 1 open bug)

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:105.0) Gecko/20100101 Firefox/105.0

Steps to reproduce:

  1. Created a native HTML checkbox.
  2. Gave it a switch role.
  3. Used script to set its state to mixed/indeterminate.
  4. Used the accessibility inspector to see how its state is exposed.

You can re-create this by:

  1. Going to https://cdpn.io/aardrian/debug/eYEgeGb
  2. Go to the group "Checkbox with switch role".
  3. Inspect the checkbox labeled "Mineral"
  4. Observe its state (for what I keep thinking of as its value).

Actual results:

The checkbox has the state/value of "mixed".

Expected results:

The checkbox should have a state/value of "false".

In my experience, developers are using native checkboxes without the aria-checked attribute when making switches, expecting the native value to carry over.

The switch role is restricted to only the values "true" or "false". The "mixed" (indeterminate) value is invalid on the switch role in the current ARIA spec and into the ARIA 1.3 Editor’s Draft:

The aria-checked attribute of a switch indicates whether the input is
on (true) or off (false). The "mixed" value is invalid, and user agents
MUST treat a mixed value as equivalent to false for this role.

https://w3c.github.io/aria/#switch

The Bugbug bot thinks this bug should belong to the 'Core::Disability Access APIs' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Disability Access APIs
Product: Firefox → Core

I agree this doesn't comply with the spec, but I do have one question:

(In reply to Adrian Roselli from comment #0)

In my experience, developers are using native checkboxes without the aria-checked attribute when making switches, expecting the native value to carry over.

In this case, though, the native value is indeterminate, rather than being checked/not checked. The checked property is preserved, but the browser effectively ignores that when indeterminate is true. I guess it makes more sense for indeterminate to map to "not checked" than it does to map it to "checked", but that is still an assumption which I don't think is specified anywhere.

Blocks: aria
Severity: -- → S3
OS: Unspecified → All
Hardware: Unspecified → All

I amended the sample to include the checkbox with aria-checked as well. I was going to file it as a different issue but then realized that is silly since these may lean on the same code (or at least any solutions should be tied together).

  1. Go to https://cdpn.io/aardrian/debug/eYEgeGb
  2. Go to the group "Checkbox with switch role and aria-checked".
  3. Inspect the checkbox labeled "Model"
  4. Observe its state (for what I keep thinking of as its value).

Its value is set to indeterminate and aria-checked="mixed". Because of the switch role, however, its value/state should be false per the ARIA note above.

And in reply to James in comment #2 above:

I guess it makes more sense for indeterminate to map to "not checked" than it does to map it to "checked", but that is still an assumption which I don't think is specified anywhere.

I think it is not specified because omitting aria-checked from a switch is unexpected/broken.

That being said, I think they should match behavior for consistency. Both the explicitly set aria-checked="mixed" (per the ARIA spec) and the programmatically set indeterminate state of the checkbox should be forced to "false" when used on a switch role.

I hope I did not just muddy this.

You need to log in before you can comment on or make changes to this bug.