Skip to content

Commit 18fbf0e

Browse files
committed
fix(select): wrong option amount being read out by NVDA
Fixes an issue that caused the wrong amount of options to be read out by NVDA. E.g. if the select has 3 options, NVDA reads out "<value> selected, 2 of 4". The issue seems to come from the fact that NVDA considers the trigger as one of the options, potentially because it's clickable.
1 parent f579ea1 commit 18fbf0e

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/lib/select/select.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
<div class="mat-select-trigger" cdk-overlay-origin (click)="toggle()" #origin="cdkOverlayOrigin" #trigger>
1+
<div
2+
cdk-overlay-origin
3+
class="mat-select-trigger"
4+
[attr.aria-hidden]="panelOpen"
5+
(click)="toggle()"
6+
#origin="cdkOverlayOrigin"
7+
#trigger>
28
<span
39
class="mat-select-placeholder"
410
[class.mat-floating-placeholder]="_selectionModel.hasValue()"

src/lib/select/select.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,6 +1688,19 @@ describe('MdSelect', () => {
16881688
subscription.unsubscribe();
16891689
});
16901690

1691+
it('should toggle aria-hidden on the trigger element', () => {
1692+
const trigger = fixture.debugElement.query(By.css('.mat-select-trigger')).nativeElement;
1693+
1694+
expect(trigger.getAttribute('aria-hidden'))
1695+
.toBe('false', 'Expected aria-hidden to be false when the select is closed.');
1696+
1697+
trigger.click();
1698+
fixture.detectChanges();
1699+
1700+
expect(trigger.getAttribute('aria-hidden'))
1701+
.toBe('true', 'Expected aria-hidden to be true when the select is open.');
1702+
});
1703+
16911704
});
16921705

16931706
describe('for options', () => {

0 commit comments

Comments
 (0)