From 56e16924b3f6a60f1671bf8ca75f948af61dedb5 Mon Sep 17 00:00:00 2001 From: Lutz Bender Date: Tue, 19 Aug 2025 08:22:51 +0200 Subject: [PATCH 1/2] fix deprecated meta tag --- packages/modules/web_themes/koala/source/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/modules/web_themes/koala/source/index.html b/packages/modules/web_themes/koala/source/index.html index 14e0fbe404..361ce4e9f9 100644 --- a/packages/modules/web_themes/koala/source/index.html +++ b/packages/modules/web_themes/koala/source/index.html @@ -7,7 +7,7 @@ - + Date: Thu, 21 Aug 2025 09:23:55 +0200 Subject: [PATCH 2/2] optimize group size calculation --- .../source/src/components/BaseCarousel.vue | 47 ++++++++++++------- .../koala/source/src/layouts/MainLayout.vue | 8 +--- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/packages/modules/web_themes/koala/source/src/components/BaseCarousel.vue b/packages/modules/web_themes/koala/source/src/components/BaseCarousel.vue index c4122bad8b..5a5d0ac250 100644 --- a/packages/modules/web_themes/koala/source/src/components/BaseCarousel.vue +++ b/packages/modules/web_themes/koala/source/src/components/BaseCarousel.vue @@ -46,36 +46,46 @@ const currentSlide = ref(0); const animated = ref(true); const carouselRef = ref<{ $el: HTMLElement } | null>(null); const itemRef = ref<(HTMLElement | null)[]>([]); -const groupSize = ref(2); -const updateGroupSize = () => { +const groupSize = computed(() => { if (!itemRef.value[0]) { - groupSize.value = 1; // Fallback to 1 if no items are available - setTimeout(updateGroupSize, 50); - return; + return; // Fallback if no item is present } - const carouselSlideWidth = - carouselRef.value?.$el.querySelector('.q-carousel__slide')?.clientWidth ?? - 0; const itemWidth = itemRef.value[0]?.clientWidth ?? 300; // Fallback - // Get computed padding from the carousel slide element + let carouselSlideWidth = 0; let padding = 0; const slideEl = carouselRef.value?.$el.querySelector('.q-carousel__slide'); if (slideEl) { + carouselSlideWidth = slideEl.clientWidth ?? 0; const style = window.getComputedStyle(slideEl); padding = parseFloat(style.paddingLeft || '0') + parseFloat(style.paddingRight || '0'); - } - groupSize.value = Math.max( + } + const maxGroupSize = Math.max( 1, Math.floor((carouselSlideWidth - padding) / itemWidth), ); -}; + + // Special case: Prevent a second group with only one item, + // if all items would fit side by side without navigation arrows + if ( + props.items.length > maxGroupSize && + props.items.length <= maxGroupSize * 2 && + props.items.length - maxGroupSize === 1 + ) { + // Check if all items would fit side by side + if (props.items.length * itemWidth <= carouselSlideWidth) { + return props.items.length; + } + } + return maxGroupSize; +}); const groupedItems = computed(() => { + const groupSizeValue = groupSize.value ? groupSize.value : props.items.length; return props.items.reduce((resultArray, item, index) => { - const chunkIndex = Math.floor(index / groupSize.value); + const chunkIndex = Math.floor(index / groupSizeValue); if (!resultArray[chunkIndex]) { resultArray[chunkIndex] = []; } @@ -86,14 +96,19 @@ const groupedItems = computed(() => { onMounted(async () => { await nextTick(() => { - updateGroupSize(); - window.addEventListener('resize', updateGroupSize); + window.addEventListener('resize', () => { + // Trigger a re-render by resetting itemRef + itemRef.value = [...itemRef.value]; + }); }); }); watch( () => props.items, - () => updateGroupSize(), + () => { + // Reset itemRef to trigger re-render + itemRef.value = [...itemRef.value]; + }, ); const handleSlideChange = () => { diff --git a/packages/modules/web_themes/koala/source/src/layouts/MainLayout.vue b/packages/modules/web_themes/koala/source/src/layouts/MainLayout.vue index c787fb655a..8dea2e77be 100644 --- a/packages/modules/web_themes/koala/source/src/layouts/MainLayout.vue +++ b/packages/modules/web_themes/koala/source/src/layouts/MainLayout.vue @@ -159,14 +159,8 @@ onMounted(() => {