Repository navigation
Description
Description
A menu bar inside a split layout leaves its overflow button outside the pane on the first render.
The pane clips the button, so the collapsed items cannot be reached at all.
Dragging the splitter by one pixel fixes it:
menu-bar-render.mp4
Trigger: the pane is sized by its content. vaadin-split-layout gives its children flex: 1 1 auto, so the pane basis follows the menu bar content.
This is not specific to split layout. Any content sized flex parent shows it, for example:
<div style="display: flex"><div style="width: 100%"></div><vaadin-menu-bar></vaadin-menu-bar></div>Reported on #3274 by @knoobie and @DiegoCardoso after that issue was closed.
Expected outcome
The overflow button stays inside the menu bar, so the collapsed items are reachable without touching the splitter.
Minimal reproducible example
<vaadin-split-layout>
<div><vaadin-menu-bar></vaadin-menu-bar></div>
<div>Resize the splitter to show the overflow button</div>
</vaadin-split-layout>
<script type="module">
import '@vaadin/menu-bar';
import '@vaadin/split-layout';
document.querySelector('vaadin-menu-bar').items = [
'View',
'Edit',
'Share',
'Move',
'Duplicate',
'Archive',
].map((text) => ({ text, children: [{ text: `${text} all` }] }));
</script>Steps to reproduce
- Open the snippet above in a window about 600px wide.
- Look at the menu bar. Four buttons are visible and the overflow button is missing.
- Drag the splitter by one pixel.
- The overflow button appears and one more item collapses.
Root cause
__setOverflowItems restores every button before it measures, so it measures a width that the menu bar only has while nothing is collapsed. Hiding a button gives it position: absolute, which lowers the max content width of the host, which lowers the pane flex basis, which shrinks the host. The decision is therefore made against a width that no longer holds once the writes land.
Instrumented on the snippet above, at a 600px window:
at gate host=348.8 all buttons span=480.2
after writes host=294.2
first render collapsed=2 overflow button 36px wide, 39px outside the host
at gate host=276.2 (after a drag, the pane has a fixed basis)
after writes host=276.2
after drag collapsed=3 overflow button 0px outside the host
Repeated detections do not converge. Each one restores the buttons first, measures 348.8px again, and reaches the same answer. Removing the container width lock added in #11358 changes nothing here, so the lock is not the cause.
Proposed solution
Either keep hiding from the current state when the host shrinks after the writes, instead of restoring every button and measuring again, or stop the intrinsic width of the host from depending on the collapse state. The second one is close to the alternative @rolfsmeds sketched in #6876. Whichever is chosen must not bring back the runaway collapse of #11269 that the container lock prevents.
Environment
Vaadin version(s): 25.1
OS: any
Browsers
Issue is not browser related
Activity
web-padawan commentedon Sep 23, 2026
Claude proposed a fix using
contain: inline-sizeandcontain-intrinsic-inline-size: var(--_vaadin-menu-bar-content-width).Prototype branch: https://github.com/vaadin/web-components/compare/proto/menu-bar-inline-size
web-padawan commentedon Sep 24, 2026
🤖 AI-generated
Summary
TL;DR
Suggested fix is behavior altering change worth landing in 25.4.
Why there is no simple fix
The menu bar hides the buttons that do not fit its width. Hidden buttons do not count toward its content width. A parent that takes its width from content then gives the menu bar less room. The earlier decision no longer holds. A new measurement repeats the same answer, because the restored buttons restore the old width. More hidden buttons do not help either, because the parent shrinks after every hide. In a shared row the menu bar always receives less than its content needs.
Why a splitter drag fixes it
A drag sets
flex: 1 1 <px>on both panes. The pane then has a fixed basis. The parent no longer takes its width from content, and the loop stops.Proposed fix
has-overflowattribute when the menu bar has collapsed buttons.--_vaadin-menu-bar-content-width.The
!importantkeeps the fix active when an application setscontainon the host.Potential impact
Fixed
Changed
auto 1frcolumn, 107 px in a flex row next to a button, 106 px in a centered toolbar, 111 px in a shrink to fit host.theme="end-aligned"the empty space is at the start.single overflow buttonin an inline block wrapper, in base, Lumo and Aura.has-overflowas a state attribute.Unchanged
Known limitations
flex-shrink: 0(fix: observe parent resize to detect overflow #3824).Note
has-overflowis a new state attribute, already used by Breadcrumbs and Avatar Group.Workarounds
The loop needs a parent that takes its width from the menu bar content. Any basis that does not come from the content stops it. Measured on
mainover 81 widths, none of these clip the overflow button.splitLayout.setSplitterPosition(50)in Flow orstyle="flex: 1 1 50%"on both panes in HTML. A percentage width on the first pane works as well.flex-shrink: 0on the menu bar. The menu bar then keeps every button and overflows the row when the row is too narrow.flex: 1 1 0on both. Each gets half of the row, so the menu bar with more items collapses first.