From 68563732fc22bf0ab842290223f788a8d9aa0288 Mon Sep 17 00:00:00 2001 From: Mate Sitchinava Date: Mon, 26 Sep 2022 14:30:47 +0400 Subject: [PATCH 01/17] fixed infinite scroll on PLP --- .../src/component/ProductList/ProductList.container.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/scandipwa/src/component/ProductList/ProductList.container.js b/packages/scandipwa/src/component/ProductList/ProductList.container.js index 3d0e818f7b..53cdb480a8 100644 --- a/packages/scandipwa/src/component/ProductList/ProductList.container.js +++ b/packages/scandipwa/src/component/ProductList/ProductList.container.js @@ -331,6 +331,8 @@ export class ProductListContainer extends PureComponent { setQueryParams({ page: pageNumber === 1 ? '' : pageNumber }, location, history); + + scrollToTop(); } render() { From 51f5a124eaa4d4cc0d3e2e306a6fd42c4b54d835 Mon Sep 17 00:00:00 2001 From: Mate Sitchinava Date: Mon, 26 Sep 2022 14:38:38 +0400 Subject: [PATCH 02/17] fixed issues related to history changes --- .../CategoryFilterOverlay.container.js | 7 +++---- .../src/component/Popup/Popup.container.js | 2 +- .../CategoryPage/CategoryPage.component.js | 17 ++++------------- .../CategoryPage/CategoryPage.container.js | 12 +++++++++--- .../ProductComparePage.container.js | 2 +- .../route/ProductPage/ProductPage.container.js | 2 +- 6 files changed, 19 insertions(+), 23 deletions(-) diff --git a/packages/scandipwa/src/component/CategoryFilterOverlay/CategoryFilterOverlay.container.js b/packages/scandipwa/src/component/CategoryFilterOverlay/CategoryFilterOverlay.container.js index a37194c5cf..27096625eb 100644 --- a/packages/scandipwa/src/component/CategoryFilterOverlay/CategoryFilterOverlay.container.js +++ b/packages/scandipwa/src/component/CategoryFilterOverlay/CategoryFilterOverlay.container.js @@ -188,10 +188,9 @@ export class CategoryFilterOverlayContainer extends PureComponent { window.addEventListener('popstate', this.historyBackHook); - history.pushState( - { overlayOpen: true }, - '', - pathname + search + history.push( + pathname + search, + { overlayOpen: true } ); } diff --git a/packages/scandipwa/src/component/Popup/Popup.container.js b/packages/scandipwa/src/component/Popup/Popup.container.js index cc8fd3ee17..b509c08142 100644 --- a/packages/scandipwa/src/component/Popup/Popup.container.js +++ b/packages/scandipwa/src/component/Popup/Popup.container.js @@ -86,7 +86,7 @@ export class PopupContainer extends PureComponent { name: POPUP, title: this._getPopupTitle(), onCloseClick: () => { - history.back(); + history.goBack(); } }); diff --git a/packages/scandipwa/src/route/CategoryPage/CategoryPage.component.js b/packages/scandipwa/src/route/CategoryPage/CategoryPage.component.js index 2c02711ba6..c48cdbdff9 100644 --- a/packages/scandipwa/src/route/CategoryPage/CategoryPage.component.js +++ b/packages/scandipwa/src/route/CategoryPage/CategoryPage.component.js @@ -14,7 +14,6 @@ import PropTypes from 'prop-types'; import { lazy, PureComponent, Suspense } from 'react'; import CategoryDetails from 'Component/CategoryDetails'; -import { CATEGORY_FILTER_OVERLAY_ID } from 'Component/CategoryFilterOverlay/CategoryFilterOverlay.config'; import CategoryItemsCount from 'Component/CategoryItemsCount'; import CategoryProductList from 'Component/CategoryProductList'; import CategorySort from 'Component/CategorySort'; @@ -59,7 +58,7 @@ export class CategoryPage extends PureComponent { sortKey: PropTypes.string }).isRequired, onSortChange: PropTypes.func.isRequired, - toggleOverlayByKey: PropTypes.func.isRequired, + onFilterButtonClick: PropTypes.func.isRequired, selectedFilters: FilterType.isRequired, filter: FilterInputType.isRequired, search: PropTypes.string, @@ -94,8 +93,6 @@ export class CategoryPage extends PureComponent { state = {}; - onFilterButtonClick = this.onFilterButtonClick.bind(this); - static getDerivedStateFromProps(props) { const { isMobile, @@ -124,12 +121,6 @@ export class CategoryPage extends PureComponent { return { activeLayoutType }; } - onFilterButtonClick() { - const { toggleOverlayByKey } = this.props; - - toggleOverlayByKey(CATEGORY_FILTER_OVERLAY_ID); - } - displayProducts() { const { category: { @@ -184,8 +175,8 @@ export class CategoryPage extends PureComponent { category: { is_anchor }, isSearchPage, isCurrentCategoryLoaded, - isMatchingInfoFilter - + isMatchingInfoFilter, + onFilterButtonClick } = this.props; if (!isMatchingInfoFilter) { @@ -200,7 +191,7 @@ export class CategoryPage extends PureComponent {