diff --git a/packages/main/cypress/specs/ToolbarSelect.cy.tsx b/packages/main/cypress/specs/ToolbarSelect.cy.tsx index 1f5ed799a161..3da2eb1a5b6a 100644 --- a/packages/main/cypress/specs/ToolbarSelect.cy.tsx +++ b/packages/main/cypress/specs/ToolbarSelect.cy.tsx @@ -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( + + + 1 + 2 + 3 + + + ); + 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"); + }); }); \ No newline at end of file diff --git a/packages/main/src/Toolbar.ts b/packages/main/src/Toolbar.ts index 12a26824d191..65a83a86c10f 100644 --- a/packages/main/src/Toolbar.ts +++ b/packages/main/src/Toolbar.ts @@ -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"); diff --git a/packages/main/src/ToolbarItem.ts b/packages/main/src/ToolbarItem.ts index 44f55f1f6c37..db9f5057e015 100644 --- a/packages/main/src/ToolbarItem.ts +++ b/packages/main/src/ToolbarItem.ts @@ -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 diff --git a/packages/main/src/ToolbarSelect.ts b/packages/main/src/ToolbarSelect.ts index 9bfce5cb4bf7..2e8451f9973d 100644 --- a/packages/main/src/ToolbarSelect.ts +++ b/packages/main/src/ToolbarSelect.ts @@ -210,7 +210,7 @@ class ToolbarSelect extends ToolbarItem { get styles() { return { - width: this.width, + width: this.isOverflowed ? undefined : this.width, }; } diff --git a/packages/main/src/themes/ToolbarSelect.css b/packages/main/src/themes/ToolbarSelect.css index d9f4dea58369..4120aba97048 100644 --- a/packages/main/src/themes/ToolbarSelect.css +++ b/packages/main/src/themes/ToolbarSelect.css @@ -2,7 +2,8 @@ width: 100%; } -.ui5-tb-popover-item { - width: inherit; +:host([is-overflowed]) .ui5-tb-popover-item { + align-items: inherit; + width: 100%; }