File tree Expand file tree Collapse file tree 1 file changed +3
-11
lines changed Expand file tree Collapse file tree 1 file changed +3
-11
lines changed Original file line number Diff line number Diff line change @@ -100,15 +100,6 @@ export class MdMenu {
100
100
this . close . emit ( null ) ;
101
101
}
102
102
103
- // When focus would shift past the start or end of the menu, wrap back to the beginning or end
104
- private _wrapIfFocusLeavesMenu ( ) : void {
105
- if ( this . _focusedItemIndex >= this . items . length ) {
106
- this . _focusedItemIndex = 0 ;
107
- } else if ( this . _focusedItemIndex < 0 ) {
108
- this . _focusedItemIndex = this . items . length - 1 ;
109
- }
110
- }
111
-
112
103
private _focusNextItem ( ) : void {
113
104
this . _updateFocusedItemIndex ( 1 ) ;
114
105
this . items . toArray ( ) [ this . _focusedItemIndex ] . focus ( ) ;
@@ -130,8 +121,9 @@ export class MdMenu {
130
121
* @private
131
122
*/
132
123
private _updateFocusedItemIndex ( delta : number , menuItems : MdMenuItem [ ] = this . items . toArray ( ) ) {
133
- this . _focusedItemIndex += delta ;
134
- this . _wrapIfFocusLeavesMenu ( ) ;
124
+ // when focus would leave menu, wrap to beginning or end
125
+ this . _focusedItemIndex = ( this . _focusedItemIndex + delta + this . items . length )
126
+ % this . items . length ;
135
127
136
128
// skip all disabled menu items recursively until an active one
137
129
// is reached or the menu closes for overreaching bounds
You can’t perform that action at this time.
0 commit comments