Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UrlInput: Stick to the ARIA 1.0 pattern #47147

Closed
afercia opened this issue Jan 13, 2023 · 0 comments · Fixed by #47148
Closed

UrlInput: Stick to the ARIA 1.0 pattern #47147

afercia opened this issue Jan 13, 2023 · 0 comments · Fixed by #47148
Assignees
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release

Comments

@afercia
Copy link
Contributor

afercia commented Jan 13, 2023

Description

I was wondering why Safari + VoiceOver fail reading the options of the UrlInput combobox while they do announce the options of the Tag suggestions. Screenshot:

Screenshot 2023-01-13 at 16 14 47

Turns out the input field of UrlInput uses aria-controls while the one of the Tag suggestions uses aria-owns. This was changed in #43278 and only for the UrlInput component.

Please notice that making a change that may look trivial can actually have a huge impact on assistive technology. Also, Safari + VoiceOver are known to be buggy with comboboxes.

It's very, very, important to actually test the impact of such changes on the most common browsers / screen reader combinations. Even the most simple changes need to be testsd.

TL;DR

The change in #43278 was made following on this comment, based on a recommendation on the MDN combobox documentation:

Note: In older ARIA specs, this was aria-owns rather than aria-controls, so you may see aria-owns in older combobox implementations. The aria-owns in the code should be updated to aria-controls!

Unfortunately, that's inaccurate.

It is true the newer ARIA specs recommends aria-controls. However, the combobox ARIA pattern evolved over time across the ARIA 1.0, 1.1, and 1.2 specs. It is important to note that the HTML structure itself changed, together with the usage of some aria-properties. To recap:

ARIA 1.2

It's still a 'Candidate Recommendation Draft', stuck on 08 December 2021. As such, it's not a official recommendation and it's not guaranteed to be implemented by vendors.
It provides an interesting note at https://www.w3.org/TR/wai-aria-1.2/#combobox

The structural requirements for combobox defined by this version of the specification are different from the requirements defined by ARIA 1.0 and ARIA 1.1:

  • The ARIA 1.0 specification required the input element with the combobox role to be a single-line text field and reference the popup element with aria-owns instead of aria-controls.
  • The ARIA 1.1 specification, which was not broadly supported by assistive technologies, required the combobox to be a non-focusable element with two required owned elements -- a focusable textbox and a popup element controlled by the textbox.
  • The changes introduced in ARIA 1.2 improve interoperability with assistive technologies and enable authors to create presentations of combobox that more closely imitate a native HTML select element.

Here's the HTML example in ARIA 1.2:

<input type="text" id="tag_combo"
      role="combobox" aria-autocomplete="list"
      aria-haspopup="listbox" aria-expanded="true"
      aria-controls="popup_listbox" aria-activedescendant="selected_option">
<ul role="listbox" id="popup_listbox">
   <li role="option"> ...

Again, we can't use this pattern.

ARIA 1.1

ARIA 1.1 is the current official recommendation, dated 14 December 2017.
As mentioned in ARIA 1.2, the 1.1 combobox pattern was not broadly supported by assistive technologies, Basically it doesn't work well and we can't use it.

Here's the HTML example in ARIA 1.1, where a div element 'owns' both the input and the listbox (via nesting and aria-owns):

<div aria-label="Tag" role="combobox" aria-expanded="true" aria-owns="owned_listbox" aria-haspopup="listbox">
    <input type="text" aria-autocomplete="list" aria-controls="owned_listbox" aria-activedescendant="selected_option">
</div>
<ul role="listbox" id="owned_listbox">
    <li role="option">Zebra</li>
    <li role="option" id="selected_option">Zoom</li>
</ul>

Again, we can't use this pattern.

ARIA 1.0

This is an old pattern but it's the only one that is currently broadly supported. It uses aria-owns in the input field.

Here's the HTML example in ARIA 1.0:

<input type="text" aria-label="Tag" role="combobox" aria-expanded="true"
  aria-autocomplete="list" aria-owns="owned_listbox" aria-activedescendant="selected_option">
<ul role="listbox" id="owned_listbox">
  <li role="option">Zebra</li>
  <li role="option" id="selected_option">Zoom</li>
</ul>

By restoring aria-owns, Safari + VoiceOver magically announce the options again.

Aside

There's one more detail that needs to be improved.
The aria-selected attribute needs to be rendered only on the 'highlighted' option and omitted from all the other options. The only allowed usage of aria-selected with a value of false in an ARIA listbox is when the Listbox allows selcting multiple items.

To clarify, here's a screenshot from the W3C ARIA Authoring Practices Editable Combobox with List Autocomplete:

Screenshot 2023-01-13 at 16 47 21

Step-by-step reproduction instructions

  • edit a post
  • use Safari and VoiceOver
  • add a link to a word in a paragraph
  • type 'hello' in the URL input search to get some link suggestions
  • use the Down and Up keys do navigate through the suggestion options
  • observe VoiceOver doesn't announce the options
  • make sure the settings sidebar displays the Post tab
  • click to add a Tag to the post
  • type something in the 'Add new tag' field to trigger the list of suggestions
  • observe VoiceOver does announce the options

Note: as mentioned above, Safari and VoiceOver are buggy anyways. When testing, you may notice some weirdness also when using the Tag selector. They announce things differently or in a buggy way e.g.:

  • sometimes they just announce {option name}, clickable
  • sometimes they announce {option name}, selected, (1 of n), completion selected (this is the expected behavior)
  • sometimes you may need to delete one of the typed characters and re-type it again to make VoiceOver announce the options

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@afercia afercia added [Type] Bug An existing feature does not function as intended [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Regression Related to a regression in the latest release labels Jan 13, 2023
@afercia afercia self-assigned this Jan 13, 2023
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Jan 13, 2023
@priethor priethor removed the [Status] In Progress Tracking issues with work in progress label May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants