-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:
Sentinel
rendering and wrong PLP's pagination behavior (#2585)
## What's the purpose of this pull request? This PR intends to fix the `Sentinel` behavior by turn it a wrapper for the `ProductGrid` component, also preventing the loop of requests happening when the user load more pages (by clicking on the `Load more products` button). ## How it works? Currently, `Sentinel` is being rendered as a side `<div />` with the `ProductGrid` component, disabling us to control the visibility of viewport elements properly. *Before* **(The red line is the `Sentinel`)** ![Screenshot 2024-12-05 at 13 07 20](https://github.com/user-attachments/assets/9ce4ccdc-a68b-46c0-8da5-a04c4ab00af7) With these changes, the `Sentinel` will wrap the `ProductGrid`, thus having the same height, enabling the use of `threshold` option (see the API options [`here`](https://github.com/thebuilder/react-intersection-observer?tab=readme-ov-file#options)) to trigger the next page (and replace the `page` query parameter) only when necessary. *After* ![Screenshot 2024-12-05 at 13 34 49](https://github.com/user-attachments/assets/08b17b71-d80d-47d2-bc19-2ffce688d541) ## How to test it? Test the `/office` page with different sizes to see if the loop of requests still happens and if the `page` query parameter is still being updated correctly. ### Starters Deploy Preview vtex-sites/starter.store#630 ## References - Using the `useInView` hook: https://github.com/thebuilder/react-intersection-observer
- Loading branch information
Showing
3 changed files
with
27 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters