@@ -1369,10 +1369,9 @@ define(function (require, exports, module) {
13691369 $menuDropdownToggle . parent ( ) . removeClass ( 'open' ) ;
13701370 const menuID = $menuDropdownToggle . parent ( ) . get ( 0 ) . id ;
13711371 const mainMenu = menuMap [ menuID ] ;
1372- const $dropdownToggles = $ ( '#titlebar .dropdown-toggle' ) ;
1372+ const $dropdownToggles = $ ( '#titlebar .dropdown:not(.hamburger-menu):visible > .dropdown -toggle' ) ;
13731373 let currentIndex = $dropdownToggles . index ( $menuDropdownToggle ) ;
1374- currentIndex = event . key === KEY . ARROW_LEFT ? currentIndex - 1 : currentIndex + 1 ;
1375- let nextIndex = currentIndex ;
1374+ let nextIndex = event . key === KEY . ARROW_LEFT ? currentIndex - 1 : currentIndex + 1 ;
13761375 if ( nextIndex < 0 ) {
13771376 nextIndex = 0 ;
13781377 } else if ( nextIndex >= $dropdownToggles . length ) {
@@ -1859,12 +1858,30 @@ define(function (require, exports, module) {
18591858 _closeHamburger ( ) ;
18601859 } ) ;
18611860
1862- // Wire up hamburger toggle mouseenter like other menus
1861+ // Close hamburger and open the hovered normal menu
1862+ $menubar . on ( "mouseenter" , ".dropdown:not(.hamburger-menu) > .dropdown-toggle" , function ( ) {
1863+ if ( $hamburger . hasClass ( "hamburger-open" ) ) {
1864+ _closeHamburger ( ) ;
1865+ // Open the hovered menu and focus its toggle so keyboard nav works
1866+ const $toggle = $ ( this ) ;
1867+ $toggle . parent ( ) . addClass ( "open" ) ;
1868+ $toggle . focus ( ) ;
1869+ }
1870+ } ) ;
1871+
1872+ // Wire up hamburger toggle mouseenter like other menus.
1873+ // If the titlebar has focus (meaning a menu is already open),
1874+ // auto-open the hamburger on hover - matching normal menu behavior.
18631875 $hamburgerToggle . on ( "mouseenter" , function ( ) {
18641876 _closeAllSubMenus ( ) ;
18651877 const $this = $ ( this ) ;
18661878 if ( $ ( '#titlebar, #titlebar *' ) . is ( ':focus' ) ) {
1879+ // Close any open normal menus first
1880+ closeAll ( ) ;
18671881 $this . addClass ( 'selected' ) . focus ( ) ;
1882+ if ( ! $hamburger . hasClass ( "hamburger-open" ) ) {
1883+ $hamburger . addClass ( "hamburger-open" ) ;
1884+ }
18681885 } else {
18691886 $this . addClass ( 'selected' ) ;
18701887 }
@@ -1908,6 +1925,8 @@ define(function (require, exports, module) {
19081925 const $items = $menubar . children ( "li.dropdown:not(.hamburger-menu)" ) ;
19091926 // First, show all items and hide hamburger to measure natural layout
19101927 $items . css ( { display : "" , position : "" , visibility : "" , pointerEvents : "" } ) ;
1928+ // Ensure hamburger is always the last item in the menu bar
1929+ $menubar . append ( $hamburger ) ;
19111930 $hamburger . hide ( ) ;
19121931 $hamburgerDropdown . empty ( ) ;
19131932
@@ -1930,11 +1949,17 @@ define(function (require, exports, module) {
19301949 return ;
19311950 }
19321951
1933- // Show hamburger, then re-check what fits with hamburger visible
1952+ // Show hamburger, then keep hiding items from the end until
1953+ // both visible items and the hamburger fit on one row
19341954 $hamburger . css ( "display" , "" ) ;
19351955
1936- // Re-measure: with hamburger visible, even more items might overflow
1937- for ( let i = 0 ; i < $items . length ; i ++ ) {
1956+ while ( overflowStartIndex > 0 && $hamburger [ 0 ] . offsetTop > firstItemTop ) {
1957+ overflowStartIndex -- ;
1958+ $ ( $items [ overflowStartIndex ] ) . css ( "display" , "none" ) ;
1959+ }
1960+
1961+ // Also check if any remaining items wrapped
1962+ for ( let i = 0 ; i < overflowStartIndex ; i ++ ) {
19381963 if ( $items [ i ] . offsetTop > firstItemTop ) {
19391964 overflowStartIndex = i ;
19401965 break ;
0 commit comments