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', () => {
73
73
page . pressKey ( protractor . Key . TAB ) ;
74
74
} ) ;
75
75
76
- it ( 'should auto-focus the first item when opened with keyboard ' , ( ) => {
76
+ it ( 'should auto-focus the first item when opened with ENTER ' , ( ) => {
77
77
page . pressKey ( protractor . Key . ENTER ) ;
78
78
page . expectFocusOn ( page . items ( 0 ) ) ;
79
79
} ) ;
80
80
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
+
81
86
it ( 'should not focus the first item when opened with mouse' , ( ) => {
82
87
page . trigger ( ) . click ( ) ;
83
88
page . expectFocusOn ( page . trigger ( ) ) ;
Original file line number Diff line number Diff line change @@ -10,4 +10,5 @@ export const RIGHT_ARROW = 39;
10
10
export const LEFT_ARROW = 37 ;
11
11
12
12
export const ENTER = 13 ;
13
+ export const SPACE = 32 ;
13
14
export const TAB = 9 ;
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import {MdMenu} from './menu-directive';
14
14
import { MdMenuMissingError } from './menu-errors' ;
15
15
import {
16
16
ENTER ,
17
+ SPACE ,
17
18
Overlay ,
18
19
OverlayState ,
19
20
OverlayRef ,
@@ -172,7 +173,7 @@ export class MdMenuTrigger implements AfterViewInit, OnDestroy {
172
173
173
174
// TODO: internal
174
175
_handleKeydown ( event : KeyboardEvent ) : void {
175
- if ( event . keyCode === ENTER ) {
176
+ if ( event . keyCode === ENTER || event . keyCode === SPACE ) {
176
177
this . _openedFromKeyboard = true ;
177
178
}
178
179
}
You can’t perform that action at this time.
0 commit comments