From cf86d54a7f09972f62f5747f034e6815cb202c11 Mon Sep 17 00:00:00 2001 From: R-Sourabh Date: Tue, 16 Apr 2024 10:57:23 +0530 Subject: [PATCH 1/3] Fixed: infinite scroll issue when used with searchbar(#289) --- src/views/AssignPickerModal.vue | 1 + src/views/Catalog.vue | 1 + src/views/Orders.vue | 5 ++++- src/views/ShipToStoreOrders.vue | 4 +++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/views/AssignPickerModal.vue b/src/views/AssignPickerModal.vue index 1ab49382b..9eaa5fc2e 100644 --- a/src/views/AssignPickerModal.vue +++ b/src/views/AssignPickerModal.vue @@ -29,6 +29,7 @@ @ionInfinite="loadMorePickers($event)" threshold="100px" :disabled="!isScrollable" + :key="queryString" > - + @@ -404,6 +406,7 @@ export default defineComponent({ } }, async searchOrders() { + console.log('serach', this.queryString); if(this.segmentSelected === 'open') { this.getPickupOrders() } else if(this.segmentSelected === 'packed') { diff --git a/src/views/ShipToStoreOrders.vue b/src/views/ShipToStoreOrders.vue index 21d9229ff..b8e8a79c5 100644 --- a/src/views/ShipToStoreOrders.vue +++ b/src/views/ShipToStoreOrders.vue @@ -90,7 +90,9 @@ - + From 5cb6b86e07a387b54fcf9ad8e6422a600d2919f1 Mon Sep 17 00:00:00 2001 From: R-Sourabh Date: Tue, 16 Apr 2024 14:53:39 +0530 Subject: [PATCH 2/3] Improved: added comment to the ion key change(#289) --- src/views/AssignPickerModal.vue | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/views/AssignPickerModal.vue b/src/views/AssignPickerModal.vue index 9eaa5fc2e..36e71c3b4 100644 --- a/src/views/AssignPickerModal.vue +++ b/src/views/AssignPickerModal.vue @@ -25,6 +25,13 @@ + Date: Wed, 17 Apr 2024 17:57:27 +0530 Subject: [PATCH 3/3] Improved: the logic for fixing infinite scroll(#289) --- src/views/AssignPickerModal.vue | 33 ++++++++++++++++++++------- src/views/Catalog.vue | 23 ++++++++++++++----- src/views/Orders.vue | 40 +++++++++++++++++++++------------ src/views/ShipToStoreOrders.vue | 39 +++++++++++++++++++++----------- 4 files changed, 95 insertions(+), 40 deletions(-) diff --git a/src/views/AssignPickerModal.vue b/src/views/AssignPickerModal.vue index 36e71c3b4..b9a3b1d37 100644 --- a/src/views/AssignPickerModal.vue +++ b/src/views/AssignPickerModal.vue @@ -10,7 +10,7 @@ - +
{{ translate('No picker found') }}
@@ -27,16 +27,18 @@ { - event.target.complete(); + ).then(async () => { + await event.target.complete(); }); }, async getPicker(vSize, vIndex) { @@ -201,6 +215,9 @@ export default defineComponent({ // getting picker information on initial load await this.getPicker(); }, + async ionViewWillEnter() { + this.isScrollingEnabled = false; + }, setup() { const store = useStore(); diff --git a/src/views/Catalog.vue b/src/views/Catalog.vue index 9968a47af..4021c5ef7 100644 --- a/src/views/Catalog.vue +++ b/src/views/Catalog.vue @@ -5,7 +5,7 @@ {{ translate("Catalog") }} - +
@@ -24,8 +24,8 @@ { - event.target.complete(); + ).then(async () => { + await event.target.complete(); }); }, async getProducts(vSize?: any, vIndex?: any) { @@ -116,6 +128,7 @@ export default defineComponent({ }, async ionViewWillEnter() { + this.isScrollingEnabled = false; this.queryString = this.products.queryString; this.getProducts(); }, diff --git a/src/views/Orders.vue b/src/views/Orders.vue index ca6d32d3c..25608770c 100644 --- a/src/views/Orders.vue +++ b/src/views/Orders.vue @@ -28,7 +28,7 @@ - +
@@ -158,8 +158,8 @@ + v-show="isScrollingEnabled && (segmentSelected === 'open' ? isOpenOrdersScrollable : segmentSelected === 'packed' ? isPackedOrdersScrollable : isCompletedOrdersScrollable)" + ref="infiniteScrollRef"> @@ -259,7 +259,8 @@ export default defineComponent({ }, data() { return { - queryString: '' + queryString: '', + isScrollingEnabled: false } }, methods: { @@ -339,28 +340,39 @@ export default defineComponent({ await this.store.dispatch("order/getCompletedOrders", { viewSize, viewIndex, queryString: this.queryString, facilityId: this.currentFacility.facilityId }); }, + enableScrolling() { + const parentElement = (this as any).$refs.contentRef.$el + const scrollEl = parentElement.shadowRoot.querySelector("main[part='scroll']") + let scrollHeight = scrollEl.scrollHeight, infiniteHeight = (this as any).$refs.infiniteScrollRef.$el.offsetHeight, scrollTop = scrollEl.scrollTop, threshold = 100, height = scrollEl.offsetHeight + const distanceFromInfinite = scrollHeight - infiniteHeight - scrollTop - threshold - height + if(distanceFromInfinite < 0) { + this.isScrollingEnabled = false; + } else { + this.isScrollingEnabled = true; + } + }, async loadMoreProducts (event: any) { if (this.segmentSelected === 'open') { this.getPickupOrders( undefined, Math.ceil(this.orders.length / process.env.VUE_APP_VIEW_SIZE).toString() - ).then(() => { - event.target.complete(); - }) + ).then(async () => { + await event.target.complete(); + }); } else if (this.segmentSelected === 'packed') { this.getPackedOrders( undefined, Math.ceil(this.packedOrders.length / process.env.VUE_APP_VIEW_SIZE).toString() - ).then(() => { - event.target.complete(); - }) + ).then(async () => { + await event.target.complete(); + }); } else { this.getCompletedOrders( undefined, Math.ceil(this.completedOrders.length / process.env.VUE_APP_VIEW_SIZE).toString() - ).then(() => { - event.target.complete(); - }) + ).then(async () => { + await event.target.complete(); + }); } }, async readyForPickup (order: any, part: any) { @@ -406,7 +418,6 @@ export default defineComponent({ } }, async searchOrders() { - console.log('serach', this.queryString); if(this.segmentSelected === 'open') { this.getPickupOrders() } else if(this.segmentSelected === 'packed') { @@ -462,6 +473,7 @@ export default defineComponent({ } }, ionViewWillEnter () { + this.isScrollingEnabled = false; this.queryString = ''; if(this.segmentSelected === 'open') { diff --git a/src/views/ShipToStoreOrders.vue b/src/views/ShipToStoreOrders.vue index b8e8a79c5..d3e6371e9 100644 --- a/src/views/ShipToStoreOrders.vue +++ b/src/views/ShipToStoreOrders.vue @@ -20,7 +20,7 @@
- +
@@ -91,8 +91,8 @@ + v-show="isScrollingEnabled && (segmentSelected === 'incoming' ? isIncomingOrdersScrollable : segmentSelected === 'readyForPickup' ? isReadyForPickupOrdersScrollable : isCompletedOrdersScrollable)" + ref="infiniteScrollRef"> @@ -180,7 +180,8 @@ export default defineComponent({ }, data() { return { - queryString: '' + queryString: '', + isScrollingEnabled: false } }, methods: { @@ -214,28 +215,39 @@ export default defineComponent({ await this.store.dispatch("order/getShipToStoreCompletedOrders", { viewSize, viewIndex, queryString: this.queryString, facilityId: this.currentFacility.facilityId }); }, + enableScrolling() { + const parentElement = (this as any).$refs.contentRef.$el + const scrollEl = parentElement.shadowRoot.querySelector("main[part='scroll']") + let scrollHeight = scrollEl.scrollHeight, infiniteHeight = (this as any).$refs.infiniteScrollRef.$el.offsetHeight, scrollTop = scrollEl.scrollTop, threshold = 100, height = scrollEl.offsetHeight + const distanceFromInfinite = scrollHeight - infiniteHeight - scrollTop - threshold - height + if(distanceFromInfinite < 0) { + this.isScrollingEnabled = false; + } else { + this.isScrollingEnabled = true; + } + }, async loadMoreOrders (event: any) { if (this.segmentSelected === 'incoming') { this.getIncomingOrders( undefined, Math.ceil(this.incomingOrders.length / process.env.VUE_APP_VIEW_SIZE).toString() - ).then(() => { - event.target.complete(); - }) + ).then(async () => { + await event.target.complete(); + }); } else if (this.segmentSelected === 'packed') { this.getReadyForPickupOrders( undefined, Math.ceil(this.readyForPickupOrders.length / process.env.VUE_APP_VIEW_SIZE).toString() - ).then(() => { - event.target.complete(); - }) + ).then(async () => { + await event.target.complete(); + }); } else { this.getCompletedOrders( undefined, Math.ceil(this.completedOrders.length / process.env.VUE_APP_VIEW_SIZE).toString() - ).then(() => { - event.target.complete(); - }) + ).then(async () => { + await event.target.complete(); + }); } }, segmentChanged (event: CustomEvent) { @@ -391,6 +403,7 @@ export default defineComponent({ }, }, ionViewWillEnter() { + this.isScrollingEnabled = false; this.queryString = ''; if (this.segmentSelected === 'incoming') { this.getIncomingOrders()