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.
This commit is contained in:
Kristiyan Kostadinov
2017-06-23 00:37:08 +02:00
committed by Jeremy Elbourn
parent 51ecc18b50
commit 2239668a3a
3 changed files with 13 additions and 3 deletions
-1
View File
@@ -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,
+1 -2
View File
@@ -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
View File
@@ -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;