Skip to content

fix(progress-bar): clear aria-valuenow in indeterminate or query mode #15019

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
Feb 22, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/lib/progress-bar/progress-bar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,49 @@ describe('MatProgressBar', () => {

expect(rect.getAttribute('fill')).toMatch(/^url\(['"]?\/another-fake-path#.*['"]?\)$/);
});

it('should remove the `aria-valuenow` attribute in indeterminate mode', () => {
const fixture = createComponent(BasicProgressBar);
fixture.detectChanges();

const progressElement = fixture.debugElement.query(By.css('mat-progress-bar'));
const progressComponent = progressElement.componentInstance;

progressComponent.mode = 'determinate';
progressComponent.value = 50;
fixture.detectChanges();

expect(progressElement.nativeElement.getAttribute('aria-valuenow'))
.toBe('50', 'Expected aria-valuenow to be set in determinate mode.');

progressComponent.mode = 'indeterminate';
fixture.detectChanges();

expect(progressElement.nativeElement.hasAttribute('aria-valuenow'))
.toBe(false, 'Expect aria-valuenow to be cleared in indeterminate mode.');
});

it('should remove the `aria-valuenow` attribute in query mode', () => {
const fixture = createComponent(BasicProgressBar);
fixture.detectChanges();

const progressElement = fixture.debugElement.query(By.css('mat-progress-bar'));
const progressComponent = progressElement.componentInstance;

progressComponent.mode = 'determinate';
progressComponent.value = 50;
fixture.detectChanges();

expect(progressElement.nativeElement.getAttribute('aria-valuenow'))
.toBe('50', 'Expected aria-valuenow to be set in determinate mode.');

progressComponent.mode = 'query';
fixture.detectChanges();

expect(progressElement.nativeElement.hasAttribute('aria-valuenow'))
.toBe(false, 'Expect aria-valuenow to be cleared in query mode.');
});

});

describe('animation trigger on determinate setting', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/progress-bar/progress-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ let progressbarId = 0;
'role': 'progressbar',
'aria-valuemin': '0',
'aria-valuemax': '100',
'[attr.aria-valuenow]': 'value',
'[attr.aria-valuenow]': '(mode === "indeterminate" || mode === "query") ? null : value',
'[attr.mode]': 'mode',
'class': 'mat-progress-bar',
'[class._mat-animation-noopable]': `_isNoopAnimation`,
'[class._mat-animation-noopable]': '_isNoopAnimation',
},
inputs: ['color'],
templateUrl: 'progress-bar.html',
Expand Down