mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
@@ -73,11 +73,16 @@ describe('menu', () => {
|
||||
page.pressKey(protractor.Key.TAB);
|
||||
});
|
||||
|
||||
it('should auto-focus the first item when opened with keyboard', () => {
|
||||
it('should auto-focus the first item when opened with ENTER', () => {
|
||||
page.pressKey(protractor.Key.ENTER);
|
||||
page.expectFocusOn(page.items(0));
|
||||
});
|
||||
|
||||
it('should auto-focus the first item when opened with SPACE', () => {
|
||||
page.pressKey(protractor.Key.SPACE);
|
||||
page.expectFocusOn(page.items(0));
|
||||
});
|
||||
|
||||
it('should not focus the first item when opened with mouse', () => {
|
||||
page.trigger().click();
|
||||
page.expectFocusOn(page.trigger());
|
||||
|
||||
@@ -10,4 +10,5 @@ export const RIGHT_ARROW = 39;
|
||||
export const LEFT_ARROW = 37;
|
||||
|
||||
export const ENTER = 13;
|
||||
export const SPACE = 32;
|
||||
export const TAB = 9;
|
||||
|
||||
@@ -14,6 +14,7 @@ import {MdMenu} from './menu-directive';
|
||||
import {MdMenuMissingError} from './menu-errors';
|
||||
import {
|
||||
ENTER,
|
||||
SPACE,
|
||||
Overlay,
|
||||
OverlayState,
|
||||
OverlayRef,
|
||||
@@ -172,7 +173,7 @@ export class MdMenuTrigger implements AfterViewInit, OnDestroy {
|
||||
|
||||
// TODO: internal
|
||||
_handleKeydown(event: KeyboardEvent): void {
|
||||
if (event.keyCode === ENTER) {
|
||||
if (event.keyCode === ENTER || event.keyCode === SPACE) {
|
||||
this._openedFromKeyboard = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user