Skip to content

Commit

Permalink
refactor: extract method for updating overflow (#3826) (#3827)
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan committed May 11, 2022
1 parent ee87eb9 commit 921f61e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/menu-bar/src/vaadin-menu-bar-buttons-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,13 @@ export const ButtonsMixin = (superClass) =>
item.classList.remove('vaadin-menu-item');
}
}
this._overflow.item = { children: [] };
this._hasOverflow = false;
this.__updateOverflow([]);
}

/** @private */
__updateOverflow(items) {
this._overflow.item = { children: items };
this._hasOverflow = items.length > 0;
}

/** @private */
Expand Down Expand Up @@ -127,9 +132,8 @@ export const ButtonsMixin = (superClass) =>
// save width for buttons with component
btn.style.width = btnStyle.width;
}
overflow.item = {
children: buttons.filter((b, idx) => idx >= i).map((b) => b.item)
};
const items = buttons.filter((_, idx) => idx >= i).map((b) => b.item);
this.__updateOverflow(items);
}
}

Expand Down

0 comments on commit 921f61e

Please sign in to comment.