Skip to content

fix(material-experimental/mdc-paginator): target page size label with aria-labelledby #23172

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

Merged
merged 1 commit into from
Jul 23, 2021

Conversation

zarend
Copy link
Contributor

@zarend zarend commented Jul 14, 2021

See commit message for description.

Original bug is filed internally at http://b/188218083

From the bug report:

ENVIRONMENT
OS | Browser | Assistive Technology
Windows version 20H2, Firefox version 88.0.1 (64-bit)
JAWS 2021 Version 2021.2102.34 ILM,
NVDA version 2020.4

PREREQUISITES
Turn on screen reader

STEPS TO REPRODUCE
Open Mozilla Firefox
Navigate to https://xap-gallery.googleplex.com/embed/a11y/mdc-paginator
Tab to the number of items combo box.
Notice the announcement.

EXPECTED RESULT(S)
the value of the combo box should be announced by the screen reader.

ACTUAL RESULT(S)
The screen reader announces the role of the combo box, but not the value . e.g. “Items per page: Combo box, To change the selection use the Arrow keys”.

ADDITIONAL NOTE(S)
This issue is only reproducible in Mozilla Firefox.

VIDEO/SCREENSHOT(S)
https://drive.google.com/file/d/1HRDaA8bXKXlduobTUmWUraAUd7v1tZ5h/view?usp=sharing&resourcekey=0-rNDyr76TRjgPc9mEQH-exg

@google-cla google-cla bot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jul 14, 2021
@zarend
Copy link
Contributor Author

zarend commented Jul 14, 2021

Kicked off a presubmit

@zarend zarend force-pushed the mdc-paginator-screenreader branch from bc47590 to 319daff Compare July 15, 2021 17:37
@zarend zarend changed the title fix(mdc-paginator): fix JAWS and NVDA not reading paginator value on fix(mdc-paginator): fix(mdc-paginator): target page size label with aria-labelledby Jul 15, 2021
@zarend zarend force-pushed the mdc-paginator-screenreader branch from 319daff to 1e38251 Compare July 15, 2021 17:46
@zarend zarend marked this pull request as ready for review July 15, 2021 17:47
@zarend zarend requested a review from crisbeto as a code owner July 15, 2021 17:47
@zarend zarend requested a review from jelbourn July 15, 2021 17:47
@zarend zarend added Accessibility This issue is related to accessibility (a11y) area: material/paginator firefox This issue is specific to the Firefox browser labels Jul 15, 2021
@zarend zarend force-pushed the mdc-paginator-screenreader branch from 1e38251 to 482e969 Compare July 15, 2021 17:49
… `aria-labelledby`

Fixes a screenrader bug on the mdc-paginator for the page size combobox
("Items per page: [combo]"). On Firefox, JAWS and NVDA do not read the
value of the combobox, and only read the label. This happens because the
mdc-paginator explicitly sets an `aria-label` on the `mdc-select` for
the page size label. This causes the mdc-select to not apply an
aria-labelledby, which would reference the value of the combobox. This
leaves us with only relying on inner text to read the value of the
combobox and not having an aria-label or labelledby to read it.

This PR corrects that behavior by refering the existing page size label
using `aria-labelledby`, and not setting an `aria-label`. The mdc-select
will append a reference to the value of the combobox to the
aria-lablledby. This gives us a list of ids of both the label and the
value of the combobox. That way we can be sure that all screenreaders
(including Windows screenreaders) will read both the value and label of
the combobox.
@zarend zarend force-pushed the mdc-paginator-screenreader branch from 482e969 to f223301 Compare July 15, 2021 17:55
@jelbourn
Copy link
Member

@zarend were you able to test this fix on Windows and confirm it addresses the issues?

@zarend
Copy link
Contributor Author

zarend commented Jul 15, 2021

Yes, I validated that this fixes the bug on Windows Firefox using the mdc-paginator demo in the dev-app.

@zarend zarend added the target: patch This PR is targeted for the next patch release label Jul 15, 2021
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -66,6 +68,10 @@ export class MatPaginator extends _MatPaginatorBase<MatPaginatorDefaultOptions>
/** If set, styles the "page size" form field with the designated style. */
_formFieldAppearance?: MatFormFieldAppearance;

/** ID for the DOM node containing the pagiators's items per page label. */
readonly _pageSizeLabelId = `mat-paginator-page-size-label-${nextUniqueId++}`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might shorten this to something like mat-pgntr-x just to shave off a few bytes

@jelbourn jelbourn added the action: merge The PR is ready for merge by the caretaker label Jul 21, 2021
@zarend zarend changed the title fix(mdc-paginator): fix(mdc-paginator): target page size label with aria-labelledby fix(material-experimental/mdc-paginator): target page size label with aria-labelledby Jul 21, 2021
@mmalerba mmalerba merged commit 85a7e45 into angular:master Jul 23, 2021
mmalerba pushed a commit that referenced this pull request Jul 23, 2021
… `aria-labelledby` (#23172)

Fixes a screenrader bug on the mdc-paginator for the page size combobox
("Items per page: [combo]"). On Firefox, JAWS and NVDA do not read the
value of the combobox, and only read the label. This happens because the
mdc-paginator explicitly sets an `aria-label` on the `mdc-select` for
the page size label. This causes the mdc-select to not apply an
aria-labelledby, which would reference the value of the combobox. This
leaves us with only relying on inner text to read the value of the
combobox and not having an aria-label or labelledby to read it.

This PR corrects that behavior by refering the existing page size label
using `aria-labelledby`, and not setting an `aria-label`. The mdc-select
will append a reference to the value of the combobox to the
aria-lablledby. This gives us a list of ids of both the label and the
value of the combobox. That way we can be sure that all screenreaders
(including Windows screenreaders) will read both the value and label of
the combobox.

(cherry picked from commit 85a7e45)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Aug 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Accessibility This issue is related to accessibility (a11y) action: merge The PR is ready for merge by the caretaker area: material/paginator cla: yes PR author has agreed to Google's Contributor License Agreement firefox This issue is specific to the Firefox browser target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants