Guttorm
(Guttorm Vik)
June 19, 2025, 11:07am
1
I have a menu that by default looks like this:
To avoid too many wrapping menu entries, I’ve tried to make it wider with:
vaadin-context-menu-list-box {
width: 35ch;
}
But, then, if there is not enough height, or I open it too far down in the screen, I get:
I now have a horizontal scrollbar as well, and the submenu markers are hidden by the vertical scrollbar.
In the browser, I have tried to set width on <vaadin-context-menu> instead but that had no effect
Tatu2
(Tatu Lund)
June 19, 2025, 11:53am
2
Guttorm Vik:
<vaadin-context-menu>
This is a quite dummy element. You would need to define the width of the overlay element instead.
Guttorm
(Guttorm Vik)
June 19, 2025, 12:00pm
3
Didn’t work to set the width of <vaadin-context-menu-overlay> either.
Looks like its default width covers the whole window. That makes sense, since it contains the menu and the submenus?
Tatu2
(Tatu Lund)
June 19, 2025, 12:21pm
4
Check the styling hints here
You should use either part overlay or content depending on the scenario what you are doing.
Guttorm
(Guttorm Vik)
June 19, 2025, 1:21pm
5
Thanks
Replacing
vaadin-context-menu-list-box {
width: 35ch;
}
with
vaadin-context-menu-overlay::part(overlay) {
width: 35ch;
}
solved the issue: