[go: nahoru, domu]

Page MenuHomePhabricator

Radio: Implement focus + unselected styles
Closed, ResolvedPublic1 Estimated Story Points

Description

The design of the Radio component includes a focused but unselected style:

Screenshot 2023-08-01 at 8.37.53 AM.png (336×642 px, 21 KB)

This style was never implemented since we did not think there was a use case for a focused but unselected Radio. Focus styles are only applied to checked radios.

However, this is not the case: when there is no initial selection and a user navigates to the radio group via keyboard, they land on the first radio (or the last one, if they shift+tab back into the group) and it becomes focused but not selected (it can be selected with space). This follows the pattern described here for the most part, although the DST engineers decided that we would prefer to allow native browser behavior to persist when it comes to shift+tabbing back into a radio group (some browsers will land the user on the last radio, which we think is acceptable).

Currently, if you keyboard navigate to a radio group with no selection, you will see no visual feedback of which radio you are on, making it very difficult to use the keyboard to use a radio group with no initial selection.


Acceptance criteria

NOTE: There is an existing proof-of-concept patch for this that just needs to be updated and merged.

  • Implement focus/unselected styles for the Radio component
  • Determine whether to also enable selection of a radio with the enter key, like we do with Checkbox (see Volker's comment; we decided not to do this)

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
AnneT triaged this task as Medium priority.Aug 1 2023, 12:44 PM
AnneT moved this task from Inbox to Up Next on the Design-System-Team board.

Note that this work has already been mostly completed with this proof-of-concept patch, which will just need to possibly implement active/unselected styles and be design reviewed.

AnneT set the point value for this task to 1.Aug 1 2023, 12:45 PM

Setting points to 1 since there is no additional design work and the implementation work is 90% done.

Change 940999 had a related patch set uploaded (by Anne Tomasevich; author: Anne Tomasevich):

[design/codex@main] Radio: Add focus styles for unchecked radios

https://gerrit.wikimedia.org/r/940999

  • I did implement use of the enter key to select a radio for the Vue version. This parallels what we do for Checkbox.
  • Active styles are already implemented, although they match the OOUI active styles, not the Codex component design spec. This should be changed in a separate task if we want to change it later.

(Somewhat repeating from patch for wider visibility)
This patch has surfaced an issue with our keyboard accessibility piece, which has slipped underneath my radar before. I'm glad this change is surfacing it.

While we need to have (Enter) a trigger for a number of components, for Checkbox and Radio, it's not expected and shouldn't be assigned in my opinion.
I assume it's been historically about having (Enter) submitting an HTML(?) form, with the key assigned only to the submit button.
You can try directly underneath the Gerrit comment field (“Resolved”), there's a native HTML checkbox which is only to be triggered by Space, not by (Enter).

I'd think we should follow and not be smarter than HTML
https://www.w3.org/WAI/ARIA/apg/patterns/radio/examples/radio-rating/#kbd_label
Alternatively, we should document why we think it's better to be smarter. But given that folks can't rely on (Enter) widely on the web, I assume following native HTML and the practices is the smarter choice.

Note that
https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Radio_Role#keyboard_interactions is featuring (Enter) after not stating it in the “Keyboard” section. I think that's just out of an over-excited dev adding the key there.

When following the APG and native HTML, this would also mean we're removing the exact same keyboard functionality from Checkbox.

Change 940999 merged by jenkins-bot:

[design/codex@main] Radio: Add focus styles for unchecked radios

https://gerrit.wikimedia.org/r/940999

Change 953351 had a related patch set uploaded (by Catrope; author: Catrope):

[mediawiki/core@master] Update Codex from v0.17.0 to v0.18.0

https://gerrit.wikimedia.org/r/953351

Change 953351 merged by jenkins-bot:

[mediawiki/core@master] Update Codex from v0.17.0 to v0.18.0

https://gerrit.wikimedia.org/r/953351