@@ -501,15 +501,16 @@ export const MenuBarMixin = (superClass) =>
501501 /** @private */
502502 __setOverflowItems ( buttons , overflow ) {
503503 const container = this . _container ;
504-
505- // Prevent the container from shrinking while buttons are being hidden.
506- // The host has min-width: 0 so it can shrink inside flex/grid layouts.
507- // Without this lock, hiding a button reduces the host width, which
508- // shrinks the container (width: 100%), shifting all button positions
509- // and causing a cascading collapse where every button appears to overflow.
510- container . style . minWidth = `${ container . offsetWidth } px` ;
511-
512- if ( container . offsetWidth < container . scrollWidth ) {
504+ // Read before any write, so a menu bar that fits forces no layout
505+ const width = container . offsetWidth ;
506+
507+ if ( width < container . scrollWidth ) {
508+ // Prevent the container from shrinking while buttons are being hidden.
509+ // The host has min-width: 0 so it can shrink inside flex/grid layouts.
510+ // Without this lock, hiding a button reduces the host width, which
511+ // shrinks the container (width: 100%), shifting all button positions
512+ // and causing a cascading collapse where every button appears to overflow.
513+ container . style . minWidth = `${ width } px` ;
513514 this . _hasOverflow = true ;
514515
515516 const isRTL = this . __isRTL ;
@@ -538,9 +539,9 @@ export const MenuBarMixin = (superClass) =>
538539
539540 const items = buttons . filter ( ( b ) => ! remaining . includes ( b ) ) . map ( ( b ) => b . item ) ;
540541 this . __updateOverflow ( items ) ;
541- }
542542
543- container . style . minWidth = '' ;
543+ container . style . minWidth = '' ;
544+ }
544545 }
545546
546547 /** @private */
0 commit comments