Skip to content

Commit b156f89

Browse files
committed
fix(menu): use narrower value for aria-haspopup on trigger element
Currently we set `aria-haspopup` correctly on the menu trigger, however [according to the spec](https://www.w3.org/TR/wai-aria-1.1/#aria-haspopup) we can narrow the value down so that it indicates what kind of popup will be opened.
1 parent eef132b commit b156f89

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/material/menu/menu-trigger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const passiveEventListenerOptions = normalizePassiveListenerOptions({passive: tr
7373
@Directive({
7474
selector: `[mat-menu-trigger-for], [matMenuTriggerFor]`,
7575
host: {
76-
'aria-haspopup': 'true',
76+
'aria-haspopup': 'menu',
7777
'[attr.aria-expanded]': 'menuOpen || null',
7878
'(mousedown)': '_handleMousedown($event)',
7979
'(keydown)': '_handleKeydown($event)',

src/material/menu/menu.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ describe('MatMenu', () => {
114114
expect(overlayContainerElement.querySelector('.cdk-overlay-backdrop')).toBeFalsy();
115115
}));
116116

117+
it('should set the correct aria-haspopup value on the trigger element', fakeAsync(() => {
118+
const fixture = createComponent(SimpleMenu, [], [FakeIcon]);
119+
fixture.detectChanges();
120+
const triggerElement = fixture.componentInstance.triggerEl.nativeElement;
121+
122+
expect(triggerElement.getAttribute('aria-haspopup')).toBe('menu');
123+
}));
124+
117125
it('should be able to remove the backdrop on repeat openings', fakeAsync(() => {
118126
const fixture = createComponent(SimpleMenu, [], [FakeIcon]);
119127
fixture.detectChanges();

0 commit comments

Comments
 (0)