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 {
100100 this . close . emit ( null ) ;
101101 }
102102
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-
112103 private _focusNextItem ( ) : void {
113104 this . _updateFocusedItemIndex ( 1 ) ;
114105 this . items . toArray ( ) [ this . _focusedItemIndex ] . focus ( ) ;
@@ -130,8 +121,9 @@ export class MdMenu {
130121 * @private
131122 */
132123 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 ;
135127
136128 // skip all disabled menu items recursively until an active one
137129 // is reached or the menu closes for overreaching bounds
You can’t perform that action at this time.
0 commit comments