From 1a07006c16b57af8aa8dcbd4ce8aea4a2e8b26ed Mon Sep 17 00:00:00 2001 From: Artur Tagisow Date: Tue, 21 Jun 2022 10:24:20 +0200 Subject: [PATCH] fix: move user to first page of products after applying filters before this commit, the page number remained unchanged after changing filters this was as problem in the scenario where: 1. open the category Women - it has 8 pages by default 2. go to page 8 3. apply some filter - eg. select "Capri" in the Material section 4. the `yarn dev` console where nuxt is running will report errors like "currentPage value 8 specified is greater than the X page(s) available" you can't know how many pages a filter will return so always returning to first page makes sense this also works ok if no products are returned --- packages/theme/modules/catalog/pages/category.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/theme/modules/catalog/pages/category.vue b/packages/theme/modules/catalog/pages/category.vue index 22fc1b231..304b235ed 100644 --- a/packages/theme/modules/catalog/pages/category.vue +++ b/packages/theme/modules/catalog/pages/category.vue @@ -236,16 +236,16 @@ export default defineComponent({ fetch(); }; - const onReloadProducts = () => { - fetch(); - productContainerElement.value.scrollIntoView(); - }; - const goToPage = (page: number) => { uiHelpers.changePage(page, false); fetch(); }; + const onReloadProducts = () => { + goToPage(0); + productContainerElement.value.scrollIntoView(); + }; + return { isPriceLoaded, ...uiHelpers,