Skip to content

Commit

Permalink
feat(ui5-toolbar): fixed spacer behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
plamenivanov91 committed Nov 14, 2024
1 parent 0315798 commit 72d0887
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
11 changes: 2 additions & 9 deletions packages/main/src/Toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,14 @@ class Toolbar extends UI5Element {
processOverflowLayout() {
const containerWidth = this.offsetWidth - this.padding;
const contentWidth = this.itemsWidth;
const overflowSpace = contentWidth - containerWidth + this.overflowButtonSize;

// skip calculation if the width has not been changed or if the items width has not been changed
if (this.width === containerWidth && this.contentWidth === contentWidth) {
return;
}

// if there is not enough space, distribute items while calculating overflow button. Otherwise don't calc overflow space/area
this.distributeItems(contentWidth > containerWidth ? contentWidth - containerWidth + this.overflowButtonSize : 0);

this.distributeItems(overflowSpace);
this.width = containerWidth;
this.contentWidth = contentWidth;
}
Expand Down Expand Up @@ -506,12 +505,6 @@ class Toolbar extends UI5Element {
}

this.closeOverflow();

// re-calculate items width if there is a dynamic spacer
if (this.hasFlexibleSpacers) {
this.storeItemsWidth();
}

this.processOverflowLayout();
}

Expand Down
4 changes: 2 additions & 2 deletions packages/main/src/ToolbarSpacer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ class ToolbarSpacer extends ToolbarItem {
}

get ignoreSpace() {
return this.width === "";
return this.width === "" || this.width === undefined || this.width === "auto";
}

get hasFlexibleWidth() {
return this.width === undefined || this.width === "auto";
return this.width === "" || this.width === undefined || this.width === "auto";
}

static get toolbarTemplate() {
Expand Down

0 comments on commit 72d0887

Please sign in to comment.