Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions packages/main/cypress/specs/ToolbarSelect.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,27 @@ describe("Toolbar general interaction", () => {
.should("have.attr", "value", "Option 3");
});
});

it("Should handle toolbar-select with width larger than the toolbar", async () => {
cy.mount(
<Toolbar id="otb_d">
<ToolbarSelect style="width: 201px;" id="toolbar-select">
<ToolbarSelectOption>1</ToolbarSelectOption>
<ToolbarSelectOption selected>2</ToolbarSelectOption>
<ToolbarSelectOption>3</ToolbarSelectOption>
</ToolbarSelect>
</Toolbar>
);
cy.viewport(220, 1080); // Set a small viewport width to trigger overflow

// Add a toolbar-select element with a large width
cy.get("#otb_d").shadow().within(() => {
cy.wait(2000);
// Click the overflow button
cy.get(".ui5-tb-overflow-btn").click();
});

// Verify the toolbar-select is rendered inside the popover
cy.get("ui5-toolbar-select").should("be.visible");
});
});
2 changes: 1 addition & 1 deletion packages/main/src/Toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ class Toolbar extends UI5Element {

let itemWidth = 0;

if (renderedItem && renderedItem.offsetWidth) {
if (renderedItem && !renderedItem.classList.contains("ui5-tb-popover-item") && renderedItem.offsetWidth && item._isRendering === false) {
const ItemCSSStyleSet = getComputedStyle(renderedItem);
itemWidth = renderedItem.offsetWidth + parsePxValue(ItemCSSStyleSet, "margin-inline-end")
+ parsePxValue(ItemCSSStyleSet, "margin-inline-start");
Expand Down
5 changes: 5 additions & 0 deletions packages/main/src/ToolbarItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ class ToolbarItem extends UI5Element {
@property({ type: Boolean })
isOverflowed: boolean = false;

_isRendering = true;

onAfterRendering(): void {
this._isRendering = false;
}
/**
* Defines if the width of the item should be ignored in calculating the whole width of the toolbar
* @protected
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/ToolbarSelect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class ToolbarSelect extends ToolbarItem {

get styles() {
return {
width: this.width,
width: this.isOverflowed ? undefined : this.width,
};
}

Expand Down
5 changes: 3 additions & 2 deletions packages/main/src/themes/ToolbarSelect.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
width: 100%;
}

.ui5-tb-popover-item {
width: inherit;
:host([is-overflowed]) .ui5-tb-popover-item {
align-items: inherit;
width: 100%;
}

Loading