Skip to content

Commit 2239668

Browse files
crisbetojelbourn
authored andcommitted
fix(menu): role being set on the wrong element (#5191)
Currently, the `menu` role is set on the `md-menu` directive, however the it is inert and won't get rendered inside the overlay. These changes remove the `menu` role from the inert element and set it on the element that will get rendered inside the overlay.
1 parent 51ecc18 commit 2239668

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/lib/menu/menu-directive.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import {ESCAPE} from '../core/keyboard/keycodes';
3333
@Component({
3434
moduleId: module.id,
3535
selector: 'md-menu, mat-menu',
36-
host: {'role': 'menu'},
3736
templateUrl: 'menu.html',
3837
styleUrls: ['menu.css'],
3938
encapsulation: ViewEncapsulation.None,

src/lib/menu/menu.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<ng-template>
22
<div class="mat-menu-panel" [ngClass]="_classList" (keydown)="_handleKeydown($event)"
3-
(click)="_emitCloseEvent()" [@transformMenu]="'showing'">
3+
(click)="_emitCloseEvent()" [@transformMenu]="'showing'" role="menu">
44
<div class="mat-menu-content" [@fadeInItems]="'showing'">
55
<ng-content></ng-content>
66
</div>
77
</div>
88
</ng-template>
9-

src/lib/menu/menu.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,18 @@ describe('MdMenu', () => {
132132
expect(panel.classList).toContain('custom-two');
133133
});
134134

135+
it('should set the "menu" role on the overlay panel', () => {
136+
const fixture = TestBed.createComponent(SimpleMenu);
137+
fixture.detectChanges();
138+
fixture.componentInstance.trigger.openMenu();
139+
fixture.detectChanges();
140+
141+
const menuPanel = overlayContainerElement.querySelector('.mat-menu-panel');
142+
143+
expect(menuPanel).toBeTruthy('Expected to find a menu panel.');
144+
expect(menuPanel.getAttribute('role')).toBe('menu', 'Expected panel to have the "menu" role.');
145+
});
146+
135147
describe('positions', () => {
136148
let fixture: ComponentFixture<PositionedMenu>;
137149
let panel: HTMLElement;

0 commit comments

Comments
 (0)