Page MenuHomePhabricator

ChipInput: Expose status message when Chip is added or removed to screen readers
Closed, ResolvedPublic2 Estimated Story Points

Description

Background

From DST's evaluating engagement with our partner AFB, we've been provided with a number of answers and tips to possible shortcomings/improvements on several of our components

In the case of the ChipInput, we were very uncertain about how to handle this from an ARIA markup perspective, as we weren't able to find great prior art for it. How could this be handled better/differently.

Most of the feedback provided for it was acceptable, with one specific case:

The screen reader must announce the status message when a new chip is added or an existing chip is removed from the list.

Goal

Use ARIA to enable exposing the addition/removal of Chips by status messages.

Technical recommendation

The aria-live attribute should ideally be placed on the smallest DOM node containing dynamically changing content to ensure screen readers announce only relevant updates. It's best to place aria-live directly on a specific child element if changes there need announcement, ensuring clear and focused information for users. Placing aria-live on a higher wrapper element might seem convenient for multiple updates but can lead to unnecessary announcements.

Acceptance criteria

  • Implement ARIA live handling on ChipInput
  • Test using a screenreader to make sure the intended behavior is working
  • Ensure the ARIA live region's status message uses the i18n composable to allow for translated strings

Shared Learnings

  • ARIA attributes used to identify the ARIA live region and process them include:
    • aria-live
    • aria-relevant
    • aria-atomic
    • aria-busy
  • The general recommendation is to use aria-live="polite" versus aria-live="assertive" unless you have a specific use case for assertive.
  • You can also define the live region type with a role attribute.
    • The ARIA status role has an implicit aria-live="polite" and an implicit aria-atomic="true".
      • role="status"
    • The ARIA alert role is a live region type with an implicit aria-live="assertive" and aria-atomic="true".
      • role="alert"
  • Example from StackOverflow

Event Timeline

Volker_E triaged this task as Medium priority.May 10 2024, 7:04 AM

It could possibly as simple as putting aria-live="polite" on .cdx-chip-input__chips listbox.
I'd also defer from using aria-busy="true" (MDN) in this case as I think it's fair to add every addition and removal to the read-out queue.

Change #1029988 had a related patch set uploaded (by VolkerE; author: VolkerE):

[design/codex@main] ChipInput: Add `aria-live` and `aria-relevant` attributes

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

lwatson set the point value for this task to 2.
lwatson changed the task status from Open to In Progress.Aug 21 2024, 1:32 AM
lwatson updated the task description. (Show Details)

I removed this item from the acceptance criteria because ChipInput does not have CSS-only examples.

Ensure markup changes are reflected in CSS-only examples

@lwatson if you've already tested this with a screen reader, I'd say this should skip design review and go to code review.

Change #1066940 had a related patch set uploaded (by LWatson; author: LWatson):

[mediawiki/core@master] i18n: add ChipInput messages for `aria-live` attribute

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

Change #1029988 merged by jenkins-bot:

[design/codex@main] ChipInput: Add ARIA live region

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

Change #1066940 merged by jenkins-bot:

[mediawiki/core@master] i18n: add ChipInput messages for `aria-live` attribute

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

Change #1070656 had a related patch set uploaded (by Eric Gardner; author: Eric Gardner):

[mediawiki/core@master] Update Codex from v1.11.1 to v1.12.0

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

Test wiki created on Patch demo by EGardner (WMF) using patch(es) linked to this task:
http://patchdemo.wmcloud.org/wikis/6bc5837bc4/w/

Change #1070656 merged by jenkins-bot:

[mediawiki/core@master] Update Codex from v1.11.1 to v1.12.0

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

  NODES
Idea 1
idea 1
Note 3
Project 9
USERS 1