Skip to content

fix(material/stepper): add text for screen readers to indicate when step is complete #23519

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

Conversation

amysorto
Copy link
Contributor

@amysorto amysorto commented Sep 2, 2021

No description provided.

@amysorto amysorto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent Accessibility This issue is related to accessibility (a11y) target: patch This PR is targeted for the next patch release labels Sep 2, 2021
@amysorto amysorto requested review from jelbourn and zarend September 2, 2021 22:49
@amysorto amysorto requested a review from mmalerba as a code owner September 2, 2021 22:49
@google-cla google-cla bot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Sep 2, 2021
Copy link
Contributor

@mmalerba mmalerba left a comment

Choose a reason for hiding this comment

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

LGTM, but need to update API goldens

@mmalerba mmalerba added action: merge The PR is ready for merge by the caretaker and removed action: merge The PR is ready for merge by the caretaker labels Sep 2, 2021
@amysorto amysorto force-pushed the announce-step-as-completed-for-screen-readers branch from 5b1c00e to d7cf8c3 Compare September 3, 2021 00:00
@amysorto amysorto requested a review from a team as a code owner September 3, 2021 00:00
@@ -10,6 +10,10 @@
[ngTemplateOutletContext]="_getIconContext()"></ng-container>
<ng-container *ngSwitchDefault [ngSwitch]="state">
<span *ngSwitchCase="'number'">{{_getDefaultTextForState(state)}}</span>
<span class="cdk-visually-hidden"
*ngIf="state == 'done' || state == 'edit'">
Copy link

Choose a reason for hiding this comment

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

Sorry for chim in, but wouldn't it be better to do it like this?

Suggested change
*ngIf="state == 'done' || state == 'edit'">
*ngIf="state === 'done' || state === 'edit'">

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we be adding this text only when the state is done? edit means that the user is still editing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @dev054!

@crisbeto @jelbourn I just updated this to have also separately have special text for "edit". I do mainly see the edit state so I figured it's worth having one too. Although your right its different than "done". Although I am not too sure if just saying editable makes sense. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe it should say something like "Current"? The only reason we have it as edit is because that's what the icon is called.

Copy link
Member

@jelbourn jelbourn Sep 7, 2021

Choose a reason for hiding this comment

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

We should already be capturing which step is selected/active by applying aria-selected to the role="tab" element, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@crisbeto @jelbourn Right now if a step is selected it will be announced because of the aria-selected attribute. Although this label is more of a way to help clarify that that tab has been started (and maybe even fully filled out) but you can come back and edit it

@@ -21,6 +21,9 @@ export class MatStepperIntl {

/** Label that is rendered below optional steps. */
optionalLabel: string = 'Optional';

/** Label that is used to indicate step as completed to screen readers. */
completedScreenReaderLabel: string = 'Completed';
Copy link
Member

Choose a reason for hiding this comment

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

This should just be completedLabel

(that fact that it's read by a screen-reader related to how it will be used rather than what it is)

@amysorto amysorto force-pushed the announce-step-as-completed-for-screen-readers branch from d7cf8c3 to fb41276 Compare September 3, 2021 18:26
@josephperrott josephperrott removed the request for review from a team September 3, 2021 19:58
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.

We should also add unit tests that assert the correct labels/descriptions are present

Comment on lines 13 to 18
<span class="cdk-visually-hidden" *ngIf="state === 'done'">
{{_intl.completedLabel}}
</span>
<span class="cdk-visually-hidden" *ngIf="state === 'edit'">
{{_intl.editableLabel}}
</span>
Copy link
Member

Choose a reason for hiding this comment

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

One thing that also occurred to me: we should compare doing this (inline text) vs. aria-describedby on the role="tab" element and see if one is preferable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I tried using the aria-describedby attribute, nothing was announced when testing with ChromeVox so I just left it as is. I also added tests

@amysorto amysorto force-pushed the announce-step-as-completed-for-screen-readers branch from fb41276 to f605fcf Compare September 9, 2021 00:58
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

@jelbourn jelbourn added the action: merge The PR is ready for merge by the caretaker label Sep 9, 2021
@mmalerba mmalerba merged commit 2602d2e into angular:master Sep 30, 2021
mmalerba pushed a commit that referenced this pull request Sep 30, 2021
…tep is complete or editable (#23519)

(cherry picked from commit 2602d2e)
@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 Oct 31, 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 cla: yes PR author has agreed to Google's Contributor License Agreement P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants