File tree Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Expand file tree Collapse file tree 3 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -73,11 +73,16 @@ describe('menu', () => {
7373 page . pressKey ( protractor . Key . TAB ) ;
7474 } ) ;
7575
76- it ( 'should auto-focus the first item when opened with keyboard ' , ( ) => {
76+ it ( 'should auto-focus the first item when opened with ENTER ' , ( ) => {
7777 page . pressKey ( protractor . Key . ENTER ) ;
7878 page . expectFocusOn ( page . items ( 0 ) ) ;
7979 } ) ;
8080
81+ it ( 'should auto-focus the first item when opened with SPACE' , ( ) => {
82+ page . pressKey ( protractor . Key . SPACE ) ;
83+ page . expectFocusOn ( page . items ( 0 ) ) ;
84+ } ) ;
85+
8186 it ( 'should not focus the first item when opened with mouse' , ( ) => {
8287 page . trigger ( ) . click ( ) ;
8388 page . expectFocusOn ( page . trigger ( ) ) ;
Original file line number Diff line number Diff line change @@ -10,4 +10,5 @@ export const RIGHT_ARROW = 39;
1010export const LEFT_ARROW = 37 ;
1111
1212export const ENTER = 13 ;
13+ export const SPACE = 32 ;
1314export const TAB = 9 ;
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import {MdMenu} from './menu-directive';
1414import { MdMenuMissingError } from './menu-errors' ;
1515import {
1616 ENTER ,
17+ SPACE ,
1718 Overlay ,
1819 OverlayState ,
1920 OverlayRef ,
@@ -172,7 +173,7 @@ export class MdMenuTrigger implements AfterViewInit, OnDestroy {
172173
173174 // TODO: internal
174175 _handleKeydown ( event : KeyboardEvent ) : void {
175- if ( event . keyCode === ENTER ) {
176+ if ( event . keyCode === ENTER || event . keyCode === SPACE ) {
176177 this . _openedFromKeyboard = true ;
177178 }
178179 }
You can’t perform that action at this time.
0 commit comments