From d5991f57581712eec670df3b23483cc3f1fc5382 Mon Sep 17 00:00:00 2001 From: Frederic Beaudoin Date: Mon, 8 Jul 2024 13:06:45 -0400 Subject: [PATCH] fix(atomic/commerce): fix url manager (#4151) https://coveord.atlassian.net/browse/KIT-3360 --- .../atomic-commerce-interface/atomic-commerce-interface.tsx | 2 +- .../atomic-commerce-product-list.tsx | 1 - .../src/pages/examples/commerce-website/listing-pants.html | 2 ++ .../examples/commerce-website/listing-surf-accessories.html | 2 ++ .../src/pages/examples/commerce-website/listing-towels.html | 2 ++ .../src/features/commerce/pagination/pagination-slice.ts | 6 +++--- packages/headless/src/features/commerce/sort/sort-slice.ts | 6 +++--- 7 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/atomic/src/components/commerce/atomic-commerce-interface/atomic-commerce-interface.tsx b/packages/atomic/src/components/commerce/atomic-commerce-interface/atomic-commerce-interface.tsx index 217e010fd31..acf41bbd5d9 100644 --- a/packages/atomic/src/components/commerce/atomic-commerce-interface/atomic-commerce-interface.tsx +++ b/packages/atomic/src/components/commerce/atomic-commerce-interface/atomic-commerce-interface.tsx @@ -438,9 +438,9 @@ export class AtomicCommerceInterface this.initRequestStatus(); this.initSummary(); - this.initUrlManager(); this.initContext(); this.initLanguage(); + this.initUrlManager(); this.initialized = true; } diff --git a/packages/atomic/src/components/commerce/atomic-commerce-product-list/atomic-commerce-product-list.tsx b/packages/atomic/src/components/commerce/atomic-commerce-product-list/atomic-commerce-product-list.tsx index 8b97c9bd5c5..45b8a7321f8 100644 --- a/packages/atomic/src/components/commerce/atomic-commerce-product-list/atomic-commerce-product-list.tsx +++ b/packages/atomic/src/components/commerce/atomic-commerce-product-list/atomic-commerce-product-list.tsx @@ -138,7 +138,6 @@ export class AtomicCommerceProductList public initialize() { if (this.bindings.interfaceElement.type === 'product-listing') { this.productListing = buildProductListing(this.bindings.engine); - this.productListing.refresh(); this.summary = this.productListing.summary(); } else { this.search = buildSearch(this.bindings.engine); diff --git a/packages/atomic/src/pages/examples/commerce-website/listing-pants.html b/packages/atomic/src/pages/examples/commerce-website/listing-pants.html index 093a620631f..26abaff0f35 100644 --- a/packages/atomic/src/pages/examples/commerce-website/listing-pants.html +++ b/packages/atomic/src/pages/examples/commerce-website/listing-pants.html @@ -16,6 +16,8 @@ const commerceInterface = document.querySelector('atomic-commerce-interface'); await commerceInterface.initializeWithEngine(commerceEngine); + + commerceInterface.executeFirstRequest(); })(); diff --git a/packages/atomic/src/pages/examples/commerce-website/listing-surf-accessories.html b/packages/atomic/src/pages/examples/commerce-website/listing-surf-accessories.html index d988bb5aa34..bda94a3c725 100644 --- a/packages/atomic/src/pages/examples/commerce-website/listing-surf-accessories.html +++ b/packages/atomic/src/pages/examples/commerce-website/listing-surf-accessories.html @@ -16,6 +16,8 @@ const commerceInterface = document.querySelector('atomic-commerce-interface'); await commerceInterface.initializeWithEngine(commerceEngine); + + commerceInterface.executeFirstRequest(); })(); diff --git a/packages/atomic/src/pages/examples/commerce-website/listing-towels.html b/packages/atomic/src/pages/examples/commerce-website/listing-towels.html index 05f2629dd85..d4dc5cfe73f 100644 --- a/packages/atomic/src/pages/examples/commerce-website/listing-towels.html +++ b/packages/atomic/src/pages/examples/commerce-website/listing-towels.html @@ -16,6 +16,8 @@ const commerceInterface = document.querySelector('atomic-commerce-interface'); await commerceInterface.initializeWithEngine(commerceEngine); + + commerceInterface.executeFirstRequest(); })(); diff --git a/packages/headless/src/features/commerce/pagination/pagination-slice.ts b/packages/headless/src/features/commerce/pagination/pagination-slice.ts index 178a9cc7bc9..715bb3d8e47 100644 --- a/packages/headless/src/features/commerce/pagination/pagination-slice.ts +++ b/packages/headless/src/features/commerce/pagination/pagination-slice.ts @@ -105,8 +105,6 @@ export const paginationReducer = createReducer( state.recommendations[slotId] = getCommercePaginationInitialSlice(); }) - .addCase(restoreSearchParameters, handleRestoreParameters) - .addCase(restoreProductListingParameters, handleRestoreParameters) .addCase(clearAllCoreFacets, handlePaginationReset) .addCase(deselectAllValuesInCoreFacet, handlePaginationReset) .addCase(toggleSelectFacetValue, handlePaginationReset) @@ -118,7 +116,9 @@ export const paginationReducer = createReducer( .addCase(toggleSelectCategoryFacetValue, handlePaginationReset) .addCase(applySort, handlePaginationReset) .addCase(setContext, handlePaginationReset) - .addCase(setView, handlePaginationReset); + .addCase(setView, handlePaginationReset) + .addCase(restoreSearchParameters, handleRestoreParameters) + .addCase(restoreProductListingParameters, handleRestoreParameters); } ); diff --git a/packages/headless/src/features/commerce/sort/sort-slice.ts b/packages/headless/src/features/commerce/sort/sort-slice.ts index 5a566d32975..d0398b26cfc 100644 --- a/packages/headless/src/features/commerce/sort/sort-slice.ts +++ b/packages/headless/src/features/commerce/sort/sort-slice.ts @@ -25,10 +25,10 @@ export const sortReducer = createReducer( }) .addCase(fetchProductListing.fulfilled, handleFetchFulfilled) .addCase(executeSearch.fulfilled, handleFetchFulfilled) - .addCase(restoreSearchParameters, handleRestoreParameters) - .addCase(restoreProductListingParameters, handleRestoreParameters) .addCase(setContext, getCommerceSortInitialState) - .addCase(setView, getCommerceSortInitialState); + .addCase(setView, getCommerceSortInitialState) + .addCase(restoreSearchParameters, handleRestoreParameters) + .addCase(restoreProductListingParameters, handleRestoreParameters); } );