Skip to content

Commit

Permalink
fix(ui5-toolbar): correct display of overflow button in hidden contai…
Browse files Browse the repository at this point in the history
…ner (SAP#10529)
  • Loading branch information
dobrinyonkov authored Jan 15, 2025
1 parent 42b29f3 commit 3a2f8e3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/main/cypress/specs/Toolbar.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,30 @@ describe("Toolbar general interaction", () => {
.find(".ui5-tb-overflow-btn-hidden")
.should("exist", "hidden class attached to tb button, meaning it's not shown as expected");
});

it("shouldn't display the overflow button when initially rendered in a hidden container and later made visible", () => {
cy.mount(html`
<div id="otb_hidden_container" style="display:none;">
<ui5-toolbar id="otb_hidden">
<ui5-toolbar-button icon="add" text="Append"></ui5-toolbar-button>
</ui5-toolbar>
</div>
`);

// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(500);

cy.get("#otb_hidden_container")
.as("hiddenContainer");

// show the hidden container
cy.get("@hiddenContainer")
.invoke("show");

// overflowbutton should not be rendered
cy.get("#otb_hidden")
.shadow()
.find(".ui5-tb-overflow-btn-hidden")
.should("exist", "hidden class attached to tb button, meaning it's not shown as expected");
});
});
3 changes: 3 additions & 0 deletions packages/main/src/Toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ class Toolbar extends UI5Element {
*/

processOverflowLayout() {
if (this.offsetWidth === 0) {
return;
}
const containerWidth = this.offsetWidth - this.padding;
const contentWidth = this.itemsWidth;
let overflowSpace = contentWidth - containerWidth + this.overflowButtonSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
@import "./ToggleButton-parameters.css";
@import "./YearPicker-parameters.css";
@import "./CalendarHeader-parameters.css";
@import "../base/Toolbar-parameters.css";
@import "./Token-parameters.css";
@import "./Tokenizer-parameters.css";
@import "./MultiComboBox-parameters.css";
Expand Down

0 comments on commit 3a2f8e3

Please sign in to comment.