New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reset Product Collection Pagination When Filtering #45693
Conversation
Since we can't be sure that a page exists once the filters have been changed we should reset the page when they do.
Hi @imanish003, Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
Test Results SummaryCommit SHA: 85f3dcd
To view the full API test report, click here. To view the full E2E test report, click here. To view all test reports, visit the WooCommerce Test Reports Dashboard. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ObliviousHarmony 👋🏻
I'm a bit puzzled about the check for paged
in the href. Shouldn't we apply the same logic as in woocommerce/woocommerce-blocks#9952 that was used for the older filter blocks?
For instance, on the 3rd page, the URL format is /155-2/?query-0-page=3
, not containing a paged
key. I've run some tests, and it seems the changes aren't functioning as anticipated due to the absence of a paged
key in the URL. Could I be overlooking something here?
Very interesting @imanish003! This seems to be a consequence of the Permalink setting I had configured.
In both cases pages with collection blocks use the the |
TIL, I wasn't aware that Plain Permalink use |
Alright @imanish003, I updated the logic for the legacy filters too 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright @imanish003, I updated the logic for the legacy filters too 😄
Thank you so much! I truly appreciate your effort. 🙏🏻 I've tested the changes, and everything is working perfectly. 🚀
Submission Review Guidelines:
Changes proposed in this Pull Request:
While it's true that the Product Collection block uses client-side refreshes, it is still vulnerable to the 404 thrown when a page does not exist. When the filters are changed while the block is looking at a page that no longer exists it will do a full page reload to a 404 page. This pull request adds a page reset so that it will return to the first page whenever the filters are changed.
Closes #45644.
How to test the changes in this Pull Request:
Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:
Changelog entry
Significance
Type
Message
Comment