Fix: Page selection will reset to 1 after deselecting filterable item, re-sorting products, and selecting new page. (https://github.com/woocommerce/woocommerce-blocks/pull/1205)

* initial commit

* change initialization state when user triggered page change
This commit is contained in:
Darren Ethier 2019-11-19 06:20:23 -05:00 committed by GitHub
parent 652aa0caa2
commit 2ca9f5eca2
1 changed files with 7 additions and 1 deletions

View File

@ -56,7 +56,11 @@ const ProductList = ( {
scrollToTop,
} ) => {
const [ queryState ] = useSynchronizedQueryState(
generateQuery( { attributes, sortValue, currentPage } )
generateQuery( {
attributes,
sortValue,
currentPage,
} )
);
const previousPage = usePrevious( queryState.page );
const isInitialized = useRef( false );
@ -71,6 +75,7 @@ const ProductList = ( {
const { products, totalProducts, productsLoading } = useStoreProducts(
queryState
);
useEffect( () => {
if ( ! productsLoading ) {
isInitialized.current = true;
@ -80,6 +85,7 @@ const ProductList = ( {
const onPaginationChange = ( newPage ) => {
scrollToTop( { focusableSelector: 'a, button' } );
onPageChange( newPage );
isInitialized.current = false;
};
const getClassnames = () => {