Skip to content

Commit b962950

Browse files
vaadin-bottomivirkkiclaude
authored
fix: menu-bar overflow detection in flex/grid layouts (#11358) (CP: 25.0) (#11360)
Co-authored-by: Tomi Virkki <tomivirkki@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d49b389 commit b962950

File tree

14 files changed

+236
-40
lines changed

14 files changed

+236
-40
lines changed

packages/menu-bar/src/styles/vaadin-menu-bar-base-styles.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { css } from 'lit';
88
export const menuBarStyles = css`
99
:host {
1010
display: block;
11+
min-width: 0;
1112
}
1213
1314
:host([hidden]) {

packages/menu-bar/src/vaadin-menu-bar-mixin.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,13 @@ export const MenuBarMixin = (superClass) =>
471471
__setOverflowItems(buttons, overflow) {
472472
const container = this._container;
473473

474+
// Prevent the container from shrinking while buttons are being hidden.
475+
// The host has min-width: 0 so it can shrink inside flex/grid layouts.
476+
// Without this lock, hiding a button reduces the host width, which
477+
// shrinks the container (width: 100%), shifting all button positions
478+
// and causing a cascading collapse where every button appears to overflow.
479+
container.style.minWidth = `${container.offsetWidth}px`;
480+
474481
if (container.offsetWidth < container.scrollWidth) {
475482
this._hasOverflow = true;
476483

@@ -501,6 +508,8 @@ export const MenuBarMixin = (superClass) =>
501508
const items = buttons.filter((b) => !remaining.includes(b)).map((b) => b.item);
502509
this.__updateOverflow(items);
503510
}
511+
512+
container.style.minWidth = '';
504513
}
505514

506515
/** @private */

0 commit comments

Comments
 (0)