From 84b0bb3ad9ceb220be504227d3b7cb6beb3e198c Mon Sep 17 00:00:00 2001 From: Christian Bedon Date: Tue, 19 Nov 2024 14:24:54 -0500 Subject: [PATCH] fix: prevent scrolling to View all button --- src/components/MyKiva/BorrowerCarousel.vue | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/MyKiva/BorrowerCarousel.vue b/src/components/MyKiva/BorrowerCarousel.vue index 23d498bd1f..58c31990c8 100644 --- a/src/components/MyKiva/BorrowerCarousel.vue +++ b/src/components/MyKiva/BorrowerCarousel.vue @@ -161,16 +161,12 @@ const carousel = ref(null); const tabs = ref(null); const windowWidth = ref(0); const openWhatIsNext = ref(false); +const lastVisitedLoanIdx = ref(0); const hasActiveLoans = computed(() => { return loans.value.some(loan => [FUNDED, FUNDRAISING, PAYING_BACK, RAISED].includes(loan?.status)); }); -const handleChange = event => { - emit('selected-loan', loans.value[event]); - carousel.value.goToSlide(event); -}; - const getBorrowerName = loan => { return loan?.name ?? ''; }; @@ -218,6 +214,16 @@ const filteredLoans = computed(() => { return loans.value.filter(loan => [FUNDED, FUNDRAISING, PAYING_BACK, RAISED].includes(loan?.status)).slice(0, 9); }); +const handleChange = event => { + if (event < filteredLoans.value.length) { + emit('selected-loan', loans.value[event]); + carousel.value.goToSlide(event); + lastVisitedLoanIdx.value = event; + } else { + tabs.value.tabContext.selectedIndex = lastVisitedLoanIdx.value; + } +}; + const singleSlideWidth = computed(() => { const viewportWidth = typeof window !== 'undefined' ? windowWidth.value : 520;