From fc5218080ea5d8d53750c77b34794b3f2e044138 Mon Sep 17 00:00:00 2001 From: Vincent BRIDIER Date: Tue, 30 Sep 2025 15:14:42 +0200 Subject: [PATCH] fix: Fix range loop on index + clean legacy feature shelf --- components/ProductList.vue | 12 +---------- pages/brands/[slug].vue | 44 +++++++++++++++++++++----------------- 2 files changed, 25 insertions(+), 31 deletions(-) diff --git a/components/ProductList.vue b/components/ProductList.vue index 863c312..478854d 100644 --- a/components/ProductList.vue +++ b/components/ProductList.vue @@ -4,10 +4,7 @@
{this.tooltips = Tooltips.make({type:"parent", parentSelector: "#product-list-component"});}); this.$nextTick(this.applySameHeight); diff --git a/pages/brands/[slug].vue b/pages/brands/[slug].vue index 2411f1c..1df8fec 100644 --- a/pages/brands/[slug].vue +++ b/pages/brands/[slug].vue @@ -5,11 +5,7 @@
; - displayShelves: boolean; tooltips: Tooltips|null; } { return { @@ -91,7 +86,6 @@ export default defineComponent({ animateTimeout: undefined, animateIndex: null, animations: ["heartBeat", "tada", "shakeX", "rubberBand"], - displayShelves: false, tooltips: null }; }, @@ -105,7 +99,6 @@ export default defineComponent({ return ; } this.brand = brand; - this.displayShelves = this.brand.shelf; const firstRange = this.brand.ranges.at(0); @@ -139,21 +132,32 @@ export default defineComponent({ chunkInefficientCustom(ranges: Array, chunkSize: number):Array> { const out: Array> = []; let row: Array = []; - ranges.forEach((range: TypeRange, i: number) => { - if (range.width === 2) { - if(row.length) { + ranges + .sort((a, b) => a.order - b.order) + .forEach((range, _i) => { + // Handle special width=2 case immediately + if (range.width === 2) { + if (row.length > 0) { + out.push(row); + row = []; + } + out.push([range]); + return; + } + + // Add to current row + row.push(range); + + // Push row if it reaches chunk size + if (row.length === chunkSize) { out.push(row); row = []; } - out.push([range]); - return; - } - row.push(range); - if (i % chunkSize) { - out.push(row); - row = []; - } - }); + }); + // Push any remaining elements + if (row.length > 0) { + out.push(row); + } return out; }, t(text: string, params: Record = {}, localeToUse: string|null = null): string {