()
| 999 | } |
| 1000 | |
| 1001 | _setItemsForStrip() { |
| 1002 | const tabStrip = this._getTabStrip(); |
| 1003 | let allItemsWidth = 0; |
| 1004 | |
| 1005 | const itemsDomRefs = this.items.map(item => item.getDomRefInStrip()) as Array<TabInStrip | TabSeparatorInStrip>; |
| 1006 | |
| 1007 | let allVisibleItemsWidth = 0; |
| 1008 | |
| 1009 | const selectedTab = this._getRootTab(this._selectedTab); |
| 1010 | const containerWidth = this._getTabStrip().offsetWidth; |
| 1011 | const selectedTabDomRef = selectedTab?.getDomRefInStrip() as TabInStrip | undefined; |
| 1012 | const visibleItemsDomRefs = itemsDomRefs.filter(item => !item.hidden); |
| 1013 | |
| 1014 | visibleItemsDomRefs.forEach(item => { |
| 1015 | allVisibleItemsWidth += this._getItemWidth(item); |
| 1016 | }); |
| 1017 | |
| 1018 | const changeTabPosition = visibleItemsDomRefs.length !== itemsDomRefs.length && this.isModeStartAndEnd && selectedTabDomRef && visibleItemsDomRefs.indexOf(selectedTabDomRef) !== -1 && allVisibleItemsWidth < containerWidth && this._getItemWidth(selectedTabDomRef) < containerWidth; |
| 1019 | |
| 1020 | // make sure the overflows are hidden |
| 1021 | this._getStartOverflow().setAttribute("hidden", ""); |
| 1022 | this._getEndOverflow().setAttribute("hidden", ""); |
| 1023 | |
| 1024 | let firstVisibleIndex; |
| 1025 | |
| 1026 | if (changeTabPosition) { |
| 1027 | firstVisibleIndex = itemsDomRefs.indexOf(visibleItemsDomRefs[0]); |
| 1028 | } |
| 1029 | |
| 1030 | // show all tabs |
| 1031 | for (let i = 0; i < itemsDomRefs.length; i++) { |
| 1032 | itemsDomRefs[i].removeAttribute("hidden"); |
| 1033 | itemsDomRefs[i].removeAttribute("start-overflow"); |
| 1034 | itemsDomRefs[i].removeAttribute("end-overflow"); |
| 1035 | } |
| 1036 | |
| 1037 | itemsDomRefs.forEach(item => { |
| 1038 | allItemsWidth += this._getItemWidth(item); |
| 1039 | }); |
| 1040 | |
| 1041 | const hasOverflow = tabStrip.offsetWidth < allItemsWidth; |
| 1042 | if (!hasOverflow) { |
| 1043 | return; |
| 1044 | } |
| 1045 | |
| 1046 | if (this.isModeStartAndEnd) { |
| 1047 | this._updateStartAndEndOverflow(itemsDomRefs, firstVisibleIndex); |
| 1048 | this._updateOverflowCounters(); |
| 1049 | } else { |
| 1050 | this._updateEndOverflow(itemsDomRefs); |
| 1051 | } |
| 1052 | } |
| 1053 | |
| 1054 | _getRootTab(tab: Tab | undefined): Tab | undefined { |
| 1055 | while (tab?.hasAttribute("ui5-tab")) { |
no test coverage detected