Skip to content

Commit e249cf6

Browse files
fix(ui5-toolbar): fix overflow layout processing in dialogs (#11894)
There was a problem with the ui5-toolbar component when used inside a dialog. The toolbar's overflow layout was not being processed correctly after the dialog was opened, leading to issues with item visibility and layout. This tracks for a similar scenario, which triggers the processOverflowLayout method of the toolbar. This ensures that the toolbar's layout is recalculated correctly after the dialog is opened, allowing the overflow items to be displayed properly. Fixes: #11771
1 parent 7c0942b commit e249cf6

File tree

2 files changed

+52
-4
lines changed

2 files changed

+52
-4
lines changed

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import type ToolbarItem from "../../src/ToolbarItem.js";
88
import add from "@ui5/webcomponents-icons/dist/add.js";
99
import decline from "@ui5/webcomponents-icons/dist/decline.js";
1010
import employee from "@ui5/webcomponents-icons/dist/employee.js";
11+
import Button from "../../src/Button.js";
12+
import Dialog from "../../src/Dialog.js";
1113

1214
describe("Toolbar general interaction", () => {
1315
it.skip("Should not return null upon calling getDomRef for all direct child items", () => {
@@ -406,4 +408,54 @@ describe("Toolbar Select", () => {
406408
});
407409
});
408410
});
411+
412+
describe("Toolbar in Dialog", () => {
413+
it("Should correctly process overflow layout when rendered inside a dialog", () => {
414+
cy.viewport(400, 600);
415+
416+
cy.mount(
417+
<div>
418+
<Button id="open-dialog-button" onClick={() => {
419+
const dialog = document.getElementById("dialog") as Dialog;
420+
dialog.open = true;
421+
}}>Open Dialog</Button>
422+
423+
<Dialog id="dialog">
424+
<Toolbar id="toolbar-in-dialog">
425+
<ToolbarButton icon={add} text="Plus" design="Default"></ToolbarButton>
426+
<ToolbarButton icon={employee} text="Hire"></ToolbarButton>
427+
<ToolbarSeparator></ToolbarSeparator>
428+
<ToolbarButton icon={add} text="Add"></ToolbarButton>
429+
<ToolbarButton icon={decline} text="Decline"></ToolbarButton>
430+
<ToolbarSpacer></ToolbarSpacer>
431+
<ToolbarButton icon={add} text="Append"></ToolbarButton>
432+
<ToolbarButton icon={employee} text="More"></ToolbarButton>
433+
<ToolbarButton icon={decline} text="Extra"></ToolbarButton>
434+
<ToolbarButton icon={add} text="Final"></ToolbarButton>
435+
<ToolbarButton icon={employee} text="Last"></ToolbarButton>
436+
<ToolbarButton icon={decline} text="Final"></ToolbarButton>
437+
<ToolbarButton icon={add} text="Plus"></ToolbarButton>
438+
</Toolbar>
439+
</Dialog>
440+
</div>
441+
);
442+
443+
// Open dialog
444+
cy.get("#open-dialog-button").click();
445+
cy.get<Dialog>("#dialog").ui5DialogOpened();
446+
447+
// Verify toolbar is rendered inside the dialog
448+
cy.get("#toolbar-in-dialog")
449+
.should("exist")
450+
.should("be.visible");
451+
452+
// Check that overflow processing has occurred by verifying overflow button exists and is visible
453+
// Since we have many items in a constrained width, some should overflow
454+
cy.get("#toolbar-in-dialog")
455+
.shadow()
456+
.find(".ui5-tb-overflow-btn")
457+
.should("exist")
458+
.should("not.have.class", "ui5-tb-overflow-btn-hidden");
459+
});
460+
});
409461
});

packages/main/src/Toolbar.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,10 +461,6 @@ class Toolbar extends UI5Element {
461461
}
462462

463463
onResize() {
464-
if (!this.itemsWidth) {
465-
return;
466-
}
467-
468464
this.closeOverflow();
469465
this.processOverflowLayout();
470466
}

0 commit comments

Comments
 (0)