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:
parent
652aa0caa2
commit
2ca9f5eca2
|
@ -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 = () => {
|
||||
|
|
Loading…
Reference in New Issue