From 910b13a88b9fe42b9d8f52a5e089528551514890 Mon Sep 17 00:00:00 2001 From: sruthin21 <125492105+sruthin21@users.noreply.github.com> Date: Wed, 18 Sep 2024 21:20:24 +0530 Subject: [PATCH 1/3] Added overflowDirection in KListWithOverflow.vue component --- lib/KListWithOverflow.vue | 48 +++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/lib/KListWithOverflow.vue b/lib/KListWithOverflow.vue index 5b65fda4a..449e2e2b7 100644 --- a/lib/KListWithOverflow.vue +++ b/lib/KListWithOverflow.vue @@ -28,6 +28,7 @@
{ + const itemWidth = itemsSizes[i].width; if (itemWidth >= availableWidth || overflowItemsIdx.length > 0) { overflowItemsIdx.push(i); - item.style.visibility = 'hidden'; - item.style.position = 'absolute'; + list.children[i].style.visibility = 'hidden'; + list.children[i].style.position = 'absolute'; } else { - item.style.visibility = 'visible'; - item.style.position = 'unset'; + list.children[i].style.visibility = 'visible'; + list.children[i].style.position = 'unset'; maxWidth += itemWidth; availableWidth -= itemWidth; const itemHeight = itemsSizes[i].height; @@ -174,7 +183,7 @@ maxHeight = itemHeight; } } - } + }); // check if overflowed items would fit if the moreButton were not visible const overflowedWidth = overflowItemsIdx.reduce( @@ -195,11 +204,17 @@ maxWidth -= removedDividerWidth; } - maxWidth = Math.ceil(maxWidth); - this.overflowItems = overflowItemsIdx.map(idx => this.items[idx]); + this.overflowItems = overflowItemsIdx.map((idx) => this.items[idx]); this.isMoreButtonVisible = overflowItemsIdx.length > 0; - list.style.maxWidth = `${maxWidth}px`; + list.style.maxWidth = `${Math.ceil(maxWidth)}px`; list.style.maxHeight = `${maxHeight}px`; + + this.setVisibleItems(directionIndexes, overflowItemsIdx); + }, + setVisibleItems(directionIndexes, overflowItemsIdx) { + // Set the visible items based on overflow logic + const visibleIndexes = directionIndexes.filter((idx) => !overflowItemsIdx.includes(idx)); + this.visibleItems = visibleIndexes.map((idx) => this.items[idx]); }, /** * Fixes the visibility of the dividers that are shown and hidden when the list overflows. @@ -276,5 +291,8 @@ .more-button-wrapper { visibility: hidden; } + .more-button-wrapper.start-button { + order: -1; /* Puts the more button at the start */ + } - + \ No newline at end of file From 966a3aa3be443fb697fbc8a59b8627538630105b Mon Sep 17 00:00:00 2001 From: sruthin21 <125492105+sruthin21@users.noreply.github.com> Date: Thu, 26 Sep 2024 00:41:16 +0530 Subject: [PATCH 2/3] Reversed ItemsSizes when overflowDirection is start --- lib/KListWithOverflow.vue | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/KListWithOverflow.vue b/lib/KListWithOverflow.vue index 449e2e2b7..564e78854 100644 --- a/lib/KListWithOverflow.vue +++ b/lib/KListWithOverflow.vue @@ -161,6 +161,9 @@ itemsSizes.push(itemSize); } + if (this.overflowDirection === 'start') { + itemsSizes.reverse(); + } const indexSequence = [...Array(list.children.length).keys()]; const directionIndexes = this.overflowDirection === 'start' ? indexSequence.reverse() : indexSequence; From 20d7e79e9c0514922d222dee0fcf53d5086a55a3 Mon Sep 17 00:00:00 2001 From: sruthin21 <125492105+sruthin21@users.noreply.github.com> Date: Fri, 27 Sep 2024 01:51:59 +0530 Subject: [PATCH 3/3] Refactor KBreadcrumbs to utilize KListWithOverflow --- lib/KBreadcrumbs.vue | 462 +++++++++---------------------------------- 1 file changed, 97 insertions(+), 365 deletions(-) diff --git a/lib/KBreadcrumbs.vue b/lib/KBreadcrumbs.vue index 6e7416111..6cc1d9b70 100644 --- a/lib/KBreadcrumbs.vue +++ b/lib/KBreadcrumbs.vue @@ -1,378 +1,110 @@