MCPcopy Create free account
hub / github.com/UI5/webcomponents / _updateOverflowItems

Method _updateOverflowItems

packages/fiori/src/SideNavigation.ts:517–587  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

515 }
516
517 _updateOverflowItems() {
518 const domRef = this.getDomRef();
519 if (!this.collapsed || !domRef) {
520 return null;
521 }
522
523 const overflowItem = this._overflowItem!;
524 const flexibleContentDomRef: HTMLElement = domRef.querySelector(".ui5-sn-flexible")!;
525 if (!overflowItem) {
526 return null;
527 }
528
529 overflowItem.classList.add("ui5-sn-item-hidden");
530
531 const overflowItems = this.overflowItems;
532
533 let itemsHeight = overflowItems.reduce<number>((sum, itemRef) => {
534 if (!itemRef) {
535 return sum;
536 }
537 itemRef.classList.remove("ui5-sn-item-hidden");
538 return sum + itemRef.offsetHeight;
539 }, 0);
540
541 const { paddingTop, paddingBottom } = window.getComputedStyle(flexibleContentDomRef);
542 const listHeight = flexibleContentDomRef?.offsetHeight - parseInt(paddingTop) - parseInt(paddingBottom);
543
544 if (itemsHeight <= listHeight) {
545 return;
546 }
547
548 overflowItem.classList.remove("ui5-sn-item-hidden");
549
550 itemsHeight = overflowItem.offsetHeight;
551
552 const selectedItem = overflowItems.filter(isInstanceOfSideNavigationSelectableItemBase).find(item => item._selected);
553
554 if (selectedItem) {
555 const selectedItemDomRef = selectedItem.getDomRef();
556
557 if (selectedItemDomRef) {
558 const { marginTop, marginBottom } = window.getComputedStyle(selectedItemDomRef);
559 itemsHeight += selectedItemDomRef.offsetHeight + parseFloat(marginTop) + parseFloat(marginBottom);
560 }
561 }
562
563 overflowItems.forEach(item => {
564 if (!item || item === selectedItem) {
565 return;
566 }
567
568 let itemDomRef;
569
570 if (isInstanceOfSideNavigationItemBase(item) && item.getDomRef()) {
571 itemDomRef = item.getDomRef();
572 } else {
573 itemDomRef = item;
574 }

Callers 1

handleResizeMethod · 0.95

Calls 3

addMethod · 0.80
removeMethod · 0.80
_initMethod · 0.80

Tested by

no test coverage detected