Skip to content

Commit f0a8f2a

Browse files
committed
Revert "Revert "Menubar: Properly track opening and closing of submenus for proper keyboard navigation""
This reverts commit fe6d244.
1 parent d5c41ac commit f0a8f2a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ui/jquery.ui.menubar.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ $.widget( "ui.menubar", {
168168
clearTimeout( that.closeTimer );
169169
}
170170
});
171+
172+
// Keep track of open submenus
173+
this.openSubmenus = 0;
171174
},
172175

173176
_destroy : function() {
@@ -218,6 +221,7 @@ $.widget( "ui.menubar", {
218221
.removeAttr( "tabIndex" );
219222
this.active = null;
220223
this.open = false;
224+
this.openSubmenus = 0;
221225
},
222226

223227
_open: function( event, menu ) {
@@ -255,10 +259,22 @@ $.widget( "ui.menubar", {
255259
},
256260

257261
next: function( event ) {
262+
if ( this.open && this.active.data( "menu" ).active.has( ".ui-menu" ).length ) {
263+
// Track number of open submenus and prevent moving to next menubar item
264+
this.openSubmenus++;
265+
return;
266+
}
267+
this.openSubmenus = 0;
258268
this._move( "next", "first", event );
259269
},
260270

261271
previous: function( event ) {
272+
if ( this.open && this.openSubmenus ) {
273+
// Track number of open submenus and prevent moving to previous menubar item
274+
this.openSubmenus--;
275+
return;
276+
}
277+
this.openSubmenus = 0;
262278
this._move( "prev", "last", event );
263279
},
264280

0 commit comments

Comments
 (0)