From 6bffb0cbf7d5dc1389c63a933e71ed2866a5d543 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Tue, 30 Jul 2024 15:01:24 +0530 Subject: [PATCH] Fixed: scrolling issue in the product filters modal (#360) --- src/components/AddProductFiltersModal.vue | 25 ++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/components/AddProductFiltersModal.vue b/src/components/AddProductFiltersModal.vue index aafbb381..e1cd76fa 100644 --- a/src/components/AddProductFiltersModal.vue +++ b/src/components/AddProductFiltersModal.vue @@ -14,7 +14,7 @@ - + @@ -50,7 +50,7 @@ - + @@ -86,14 +86,17 @@ import { useStore } from "vuex"; import { translate } from '@hotwax/dxp-components'; const queryString = ref(''); -const isScrollable = ref(true); const selectedValues = ref([]) as any; -const isLoading = ref(false); const filteredOptions = ref([]) as any; - const pageSize = process.env.VUE_APP_VIEW_SIZE; const currentPage = ref(0); +const isScrollable = ref(true); +const isLoading = ref(false); +const isScrollingEnabled = ref(false); +const contentRef = ref({}) as any; +const infiniteScrollRef = ref({}) as any; + const props = defineProps(["label", "facetToSelect", "searchfield", "type"]); const store = useStore(); @@ -157,6 +160,18 @@ async function saveFilters() { await store.dispatch('util/updateAppliedFilters', selectedFilters) modalController.dismiss() } + +function enableScrolling() { + const parentElement = contentRef.value.$el + const scrollEl = parentElement.shadowRoot.querySelector("main[part='scroll']") + let scrollHeight = scrollEl.scrollHeight, infiniteHeight = infiniteScrollRef.value.$el.offsetHeight, scrollTop = scrollEl.scrollTop, threshold = 100, height = scrollEl.offsetHeight + const distanceFromInfinite = scrollHeight - infiniteHeight - scrollTop - threshold - height + if(distanceFromInfinite < 0) { + isScrollingEnabled.value = false; + } else { + isScrollingEnabled.value = true; + } +}