Skip to content

Commit f7f98d6

Browse files
fix(ui5-toolbar): prevent flickering (#12285)
* fix(ui5-toolbar): prevent flickering * fix(ui5-toolbar): prevent flickering
1 parent f6a0504 commit f7f98d6

File tree

5 files changed

+33
-4
lines changed

5 files changed

+33
-4
lines changed

packages/main/cypress/specs/ToolbarSelect.cy.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,4 +259,27 @@ describe("Toolbar general interaction", () => {
259259
.should("have.attr", "value", "Option 3");
260260
});
261261
});
262+
263+
it("Should handle toolbar-select with width larger than the toolbar", async () => {
264+
cy.mount(
265+
<Toolbar id="otb_d">
266+
<ToolbarSelect style="width: 201px;" id="toolbar-select">
267+
<ToolbarSelectOption>1</ToolbarSelectOption>
268+
<ToolbarSelectOption selected>2</ToolbarSelectOption>
269+
<ToolbarSelectOption>3</ToolbarSelectOption>
270+
</ToolbarSelect>
271+
</Toolbar>
272+
);
273+
cy.viewport(220, 1080); // Set a small viewport width to trigger overflow
274+
275+
// Add a toolbar-select element with a large width
276+
cy.get("#otb_d").shadow().within(() => {
277+
cy.wait(2000);
278+
// Click the overflow button
279+
cy.get(".ui5-tb-overflow-btn").click();
280+
});
281+
282+
// Verify the toolbar-select is rendered inside the popover
283+
cy.get("ui5-toolbar-select").should("be.visible");
284+
});
262285
});

packages/main/src/Toolbar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ class Toolbar extends UI5Element {
499499

500500
let itemWidth = 0;
501501

502-
if (renderedItem && renderedItem.offsetWidth) {
502+
if (renderedItem && !renderedItem.classList.contains("ui5-tb-popover-item") && renderedItem.offsetWidth && item._isRendering === false) {
503503
const ItemCSSStyleSet = getComputedStyle(renderedItem);
504504
itemWidth = renderedItem.offsetWidth + parsePxValue(ItemCSSStyleSet, "margin-inline-end")
505505
+ parsePxValue(ItemCSSStyleSet, "margin-inline-start");

packages/main/src/ToolbarItem.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ class ToolbarItem extends UI5Element {
6060
@property({ type: Boolean })
6161
isOverflowed: boolean = false;
6262

63+
_isRendering = true;
64+
65+
onAfterRendering(): void {
66+
this._isRendering = false;
67+
}
6368
/**
6469
* Defines if the width of the item should be ignored in calculating the whole width of the toolbar
6570
* @protected

packages/main/src/ToolbarSelect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class ToolbarSelect extends ToolbarItem {
210210

211211
get styles() {
212212
return {
213-
width: this.width,
213+
width: this.isOverflowed ? undefined : this.width,
214214
};
215215
}
216216

packages/main/src/themes/ToolbarSelect.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
width: 100%;
33
}
44

5-
.ui5-tb-popover-item {
6-
width: inherit;
5+
:host([is-overflowed]) .ui5-tb-popover-item {
6+
align-items: inherit;
7+
width: 100%;
78
}
89

0 commit comments

Comments
 (0)