Skip to content

Commit

Permalink
fix: do not expand to full available width (#3506)
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan committed Mar 1, 2022
1 parent 36dea1b commit 711bfca
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/menu-bar/src/vaadin-menu-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class MenuBar extends ButtonsMixin(DisabledMixin(InteractionsMixin(ElementMixin(
<style>
:host {
display: block;
width: 100%; /* make overflow work in flex */
align-self: stretch; /* make overflow work in flex */
}
:host([hidden]) {
Expand Down
19 changes: 19 additions & 0 deletions packages/menu-bar/test/menu-bar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -603,3 +603,22 @@ describe('item components', () => {
expect(Number(style.zIndex)).to.equal(1);
});
});

describe('menu-bar in flex', () => {
let wrapper;
let menu;

beforeEach(() => {
wrapper = fixtureSync(`
<div style="display: flex; width: 400px;">
<vaadin-menu-bar></vaadin-menu-bar>
</div>
`);
menu = wrapper.firstElementChild;
menu.items = [{ text: 'Item 1' }, { text: 'Item 2' }, { text: 'Item 3' }];
});

it('should not expand to full width of the container', () => {
expect(menu.offsetWidth).to.be.lessThan(wrapper.offsetWidth);
});
});

2 comments on commit 711bfca

@darjag
Copy link

@darjag darjag commented on 711bfca Mar 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's better, but brake vertical align:
image

PK and + is MenuBar

@web-padawan
Copy link
Member Author

@web-padawan web-padawan commented on 711bfca Mar 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@darjag I'm afraid we can't make it work for all cases because the original intent was to fix vaadin-menu-bar overflow when it is placed in the element with flex-direction: column, but it causes problems when trying to center vaadin-menu-bar in the container setting flex-direction: row. We had this issue for other components e.g. #991 (the same fix was previously applied in vaadin/vaadin-form-layout#107)

Please sign in to comment.