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

fix(material/stepper): remove invalid aria attribute #25644

Merged
merged 1 commit into from Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cdk/stepper/stepper.md
Expand Up @@ -63,6 +63,6 @@ your own component, it is recommended that the stepper is treated as a tabbed vi
purposes by giving it a `role="tablist"`. The header of step that can be clicked to select the step
should be given `role="tab"`, and the content that can be expanded upon selection should be given
`role="tabpanel"`. Furthermore, the step header should have an `aria-selected` attribute that
reflects its selected state and the associated content element should have `aria-expanded`.
reflects its selected state.

You can refer to the [Angular Material stepper](https://github.com/angular/components/tree/main/src/material/stepper) as an example of an accessible implementation.
4 changes: 2 additions & 2 deletions src/material/stepper/stepper.html
Expand Up @@ -20,7 +20,7 @@
(@horizontalStepTransition.done)="_animationDone.next($event)"
[id]="_getStepContentId(i)"
[attr.aria-labelledby]="_getStepLabelId(i)"
[attr.aria-expanded]="selectedIndex === i">
[class.mat-horizontal-stepper-content-inactive]="selectedIndex !== i">
<ng-container [ngTemplateOutlet]="step.content"></ng-container>
</div>
</div>
Expand All @@ -41,7 +41,7 @@
(@verticalStepTransition.done)="_animationDone.next($event)"
[id]="_getStepContentId(i)"
[attr.aria-labelledby]="_getStepLabelId(i)"
[attr.aria-expanded]="selectedIndex === i">
[class.mat-vertical-stepper-content-inactive]="selectedIndex !== i">
<div class="mat-vertical-content">
<ng-container [ngTemplateOutlet]="step.content"></ng-container>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/material/stepper/stepper.md
Expand Up @@ -231,8 +231,8 @@ export class MyApp {}
The stepper is treated as a tabbed view for accessibility purposes, so it is given
`role="tablist"` by default. The header of step that can be clicked to select the step
is given `role="tab"`, and the content that can be expanded upon selection is given
`role="tabpanel"`. `aria-selected` attribute of step header and `aria-expanded` attribute of
step content is automatically set based on step selection change.
`role="tabpanel"`. `aria-selected` attribute of step header is automatically set based on
step selection change.

The stepper and each step should be given a meaningful label via `aria-label` or `aria-labelledby`.

Expand Down
2 changes: 1 addition & 1 deletion src/material/stepper/stepper.scss
Expand Up @@ -129,7 +129,7 @@
.mat-horizontal-stepper-content {
outline: 0;

&[aria-expanded='false'] {
&.mat-horizontal-stepper-content-inactive {
height: 0;
overflow: hidden;
}
Expand Down
16 changes: 0 additions & 16 deletions src/material/stepper/stepper.spec.ts
Expand Up @@ -131,22 +131,6 @@ describe('MatStepper', () => {
expect(stepperEl.getAttribute('role')).toBe('tablist');
});

it('should set aria-expanded of content correctly', () => {
const stepContents = fixture.debugElement.queryAll(By.css(`.mat-vertical-stepper-content`));
const stepperComponent = fixture.debugElement.query(
By.directive(MatStepper),
)!.componentInstance;
const firstStepContentEl = stepContents[0].nativeElement;
expect(firstStepContentEl.getAttribute('aria-expanded')).toBe('true');

stepperComponent.selectedIndex = 1;
fixture.detectChanges();

expect(firstStepContentEl.getAttribute('aria-expanded')).toBe('false');
const secondStepContentEl = stepContents[1].nativeElement;
expect(secondStepContentEl.getAttribute('aria-expanded')).toBe('true');
});

it('should display the correct label', () => {
const stepperComponent = fixture.debugElement.query(
By.directive(MatStepper),
Expand Down