Skip to content

Commit

Permalink
fix(menu): role being set on the wrong element (#5191)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
crisbeto authored and jelbourn committed Jun 22, 2017
1 parent 51ecc18 commit 2239668
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/lib/menu/menu-directive.ts
Expand Up @@ -33,7 +33,6 @@ import {ESCAPE} from '../core/keyboard/keycodes';
@Component({
moduleId: module.id,
selector: 'md-menu, mat-menu',
host: {'role': 'menu'},
templateUrl: 'menu.html',
styleUrls: ['menu.css'],
encapsulation: ViewEncapsulation.None,
Expand Down
3 changes: 1 addition & 2 deletions src/lib/menu/menu.html
@@ -1,9 +1,8 @@
<ng-template>
<div class="mat-menu-panel" [ngClass]="_classList" (keydown)="_handleKeydown($event)"
(click)="_emitCloseEvent()" [@transformMenu]="'showing'">
(click)="_emitCloseEvent()" [@transformMenu]="'showing'" role="menu">
<div class="mat-menu-content" [@fadeInItems]="'showing'">
<ng-content></ng-content>
</div>
</div>
</ng-template>

12 changes: 12 additions & 0 deletions src/lib/menu/menu.spec.ts
Expand Up @@ -132,6 +132,18 @@ describe('MdMenu', () => {
expect(panel.classList).toContain('custom-two');
});

it('should set the "menu" role on the overlay panel', () => {
const fixture = TestBed.createComponent(SimpleMenu);
fixture.detectChanges();
fixture.componentInstance.trigger.openMenu();
fixture.detectChanges();

const menuPanel = overlayContainerElement.querySelector('.mat-menu-panel');

expect(menuPanel).toBeTruthy('Expected to find a menu panel.');
expect(menuPanel.getAttribute('role')).toBe('menu', 'Expected panel to have the "menu" role.');
});

describe('positions', () => {
let fixture: ComponentFixture<PositionedMenu>;
let panel: HTMLElement;
Expand Down

0 comments on commit 2239668

Please sign in to comment.