Skip to content

Commit 20ca05b

Browse files
committed
fix(autocomplete): aria-expanded should be updated when panel hides
1 parent d78a370 commit 20ca05b

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/lib/autocomplete/autocomplete-trigger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy {
114114

115115
/* Whether or not the autocomplete panel is open. */
116116
get panelOpen(): boolean {
117-
return this._panelOpen;
117+
return this._panelOpen && this.autocomplete.showPanel;
118118
}
119119

120120
/** Opens the autocomplete suggestion panel. */

src/lib/autocomplete/autocomplete.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,27 @@ describe('MdAutocomplete', () => {
762762
});
763763
}));
764764

765+
it('should set aria-expanded properly when the panel is hidden', async(() => {
766+
fixture.componentInstance.trigger.openPanel();
767+
768+
fixture.whenStable().then(() => {
769+
fixture.detectChanges();
770+
expect(input.getAttribute('aria-expanded'))
771+
.toBe('true', 'Expected aria-expanded to be true while panel is open.');
772+
773+
typeInElement('zz', input);
774+
fixture.whenStable().then(() => {
775+
fixture.detectChanges();
776+
777+
fixture.whenStable().then(() => {
778+
fixture.detectChanges();
779+
expect(input.getAttribute('aria-expanded'))
780+
.toBe('false', 'Expected aria-expanded to be false when panel hides itself.');
781+
});
782+
});
783+
});
784+
}));
785+
765786
it('should set aria-owns based on the attached autocomplete', () => {
766787
fixture.componentInstance.trigger.openPanel();
767788
fixture.detectChanges();

0 commit comments

Comments
 (0)