Skip to content

fix: PLP "Load more products" overwriting list instead of appending - #3308

Merged
lemagnetic merged 2 commits into
devfrom
fix/plp-infinity-scroll-overiwriting
May 11, 2026
Merged

lemagnetic merged 2 commits into
devfrom
fix/plp-infinity-scroll-overiwriting

Conversation

@lemagnetic

Copy link
Copy Markdown
Contributor

What's the purpose of this pull request?

On a PLP, clicking "Load more products" was supposed to append the next 12 products below the existing 12. Instead, the new page replaced the current list, so the user kept seeing only 12 items.

Root cause: the Provider in @faststore/sdk was resetting the infinite-scroll pages array on every URL change reaching <SearchProvider>. Two converging conditions made it fire on a Sentinel-triggered URL update:

  1. parseSearchState always returns a new selectedFacets array reference, even when the content is identical.
  2. The Sentinel reflects the page in viewport into the URL via router.replace('?page=N'). That update bubbles back to the Provider via asPath, and the effect's referential deps fire, calling resetInfiniteScroll(N), which collapses pages to [N].

How it works?

The useEffect in packages/sdk/src/search/Provider.tsx was split into two with different responsibilities:

  • setState(rest) keeps running on any change to term, sort, selectedFacets, or page — preserving the search-context sync introduced in fix: search update #3015.
  • resetInfiniteScroll now runs only when the content of the search (term / sort / selectedFacets) changes, gated by a stable, content-based key built via JSON.stringify. Page-only URL updates no longer trigger a reset.

rest.page is intentionally excluded from the reset effect's deps. React closures still capture the latest value at the moment the effect runs, so when content actually changes (e.g., the user toggles a filter, which atomically also sets page: 0), the reset uses the correct page. An eslint-disable with a code comment documents the intent.

How to test it?

Pre-conditions: any PLP with more than 12 products and "Load more products" enabled.

  • Open a PLP, confirm the first 12 products render.
  • Click Load more products , the next 12 products must be appended below the original 12 (24 in total). Repeat the click — 36, 48, and so on.
  • Toggle a filter while having multiple pages stacked, the gallery must reset to the first page of the new filtered results.
  • Change the Sort while having multiple pages stacked, same expected reset.
  • Reload the page on a deep-link such as /<plp>?page=2, the gallery should open directly on page 2 (deep-link still works).
  • Use the browser Back / Forward buttons after stacking pages, navigation works as usual.

Starters Deploy Preview

URL Preview with fix

References

  • Jira ticket: SFS-3162
  • fix: search update #3015 (fix: search update) — introduced the dependency-array on the Provider effect that, combined with the Sentinel, caused the regression.

Summary by CodeRabbit

  • Bug Fixes
    • More reliable infinite-scroll reset so results reload consistently when search term, sort order, or filters change.
  • Style
    • Improved product grid responsive spacing and bottom padding across mobile, tablet, notebook, and desktop breakpoints for more consistent layout and pagination spacing.

Review Change Stack

@lemagnetic
lemagnetic requested a review from a team as a code owner May 11, 2026 16:31
@lemagnetic
lemagnetic requested review from hellofanny and ommeirelles and removed request for a team May 11, 2026 16:31
@coderabbitai

coderabbitai Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@lemagnetic has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 43 minutes and 34 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6f5463f1-bcc3-4dc3-a50b-4520cb390a0b

📥 Commits

Reviewing files that changed from the base of the PR and between 78469e6 and 5df1f45.

📒 Files selected for processing (2)
  • packages/sdk/src/search/Provider.tsx
  • packages/ui/src/components/organisms/ProductGrid/styles.scss
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/plp-infinity-scroll-overiwriting

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codesandbox-ci

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@coderabbitai

coderabbitai Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@lemagnetic has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 43 minutes and 34 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6f5463f1-bcc3-4dc3-a50b-4520cb390a0b

📥 Commits

Reviewing files that changed from the base of the PR and between 78469e6 and 5df1f45.

📒 Files selected for processing (2)
  • packages/sdk/src/search/Provider.tsx
  • packages/ui/src/components/organisms/ProductGrid/styles.scss
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/plp-infinity-scroll-overiwriting

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@lemagnetic
lemagnetic merged commit e8b08cd into dev May 11, 2026
4 checks passed
@lemagnetic
lemagnetic deleted the fix/plp-infinity-scroll-overiwriting branch May 11, 2026 18:18
eduardoformiga added a commit that referenced this pull request May 11, 2026
## What's the purpose of this pull request?

Bring `dev` into `main` so the next CD run on `main` cuts and publishes
`@faststore/*@4.1.0`. Includes the publish-pipeline fix from #3309, so
this is also the first release that exercises the `pnpm -r publish` flow
end-to-end (broken `4.0.0` is superseded by `4.1.0` as `latest`).

## What's included since v4.0.0

- #3308 — fix: PLP "Load more products" overwriting list instead of
appending
- #3306 — feat: user details adjusts — SFS-2950
- #3304 — fix: updates schemas vtex.faststore
- #3301 — fix: localization selector stale and reset selection for
unsaved changes
- `d1e40abe7` — fix: add repository field to diagnostics package for
OIDC provenance
- #3309 — fix: publish releases with pnpm to resolve workspace and
catalog protocols (already on `main`, kept by 3-way merge)

## How CD will behave on merge

1. `lerna version --conventional-commits --conventional-graduate --yes`
graduates `4.1.0-dev.1` → `4.1.0`, creates tag `v4.1.0`, and pushes the
`[no ci] Release: 4.1.0` commit.
2. `pnpm release:verify` packs every public package and asserts no
`workspace:` / `catalog:` literal survives the pack step.
3. `pnpm -r publish --access public --no-git-checks` uploads the 8
public packages with all `workspace:*` / `catalog:` references rewritten
to concrete versions.

## Sanity checks already performed locally

- `git merge-tree` between `origin/main` and `origin/dev`: clean, no
conflicts.
- `pnpm install --frozen-lockfile` on the merged tree: no lockfile
drift.
- `pnpm release:verify` on `release/4.1.0`: all 8 public packages clean
at `4.1.0-dev.1` (the same manifests that will be bumped to `4.1.0`).

## Follow-ups (not blocking)

- Once `4.1.0` is on `latest`, consider `npm deprecate
@faststore/<pkg>@4.0.0 "Broken release: workspace:/catalog: not
resolved. Use 4.1.0+"` for `cli`, `core`, `api`, `ui`, `components`,
`sdk`, `diagnostics`, `lighthouse`.
- Optional: add `workflow_dispatch` to `release.yml` so future hotfix
releases without `packages/*` changes can be triggered manually with
`--force-publish`.

Made with [Cursor](https://cursor.com)

---------

Co-authored-by: Larícia Mota <[email protected]>
Co-authored-by: Matheus P. Silva <[email protected]>
Co-authored-by: Leandro Rodrigues <[email protected]>
Co-authored-by: vtexgithubbot <[email protected]>
Co-authored-by: Lucas Feijó <[email protected]>
Co-authored-by: Luiz Falcão <[email protected]>
Co-authored-by: Artur Santiago <[email protected]>
Co-authored-by: Sahan Jayawardana <[email protected]>
Co-authored-by: Mateus Pontes <[email protected]>
Co-authored-by: Matheus Martins <[email protected]>
Co-authored-by: renatomaurovtex <[email protected]>
Co-authored-by: Leandro Rodrigues <[email protected]>
Co-authored-by: Fanny Chien <[email protected]>
Co-authored-by: Arthur Andrade <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Thiago Pereira <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Giuliana Rigaud <[email protected]>
Co-authored-by: renato <[email protected]>
Co-authored-by: Bruna Santos <[email protected]>
Co-authored-by: BrunaCubos <[email protected]>
Co-authored-by: Ícaro Oliveira <[email protected]>
Co-authored-by: Bruna Santos <[email protected]>
Co-authored-by: Everton Ataide <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: Otavio Moreira Meirelles <[email protected]>
Co-authored-by: Marco Cardoso <[email protected]>
Co-authored-by: Gabriel Paladino <[email protected]>
Co-authored-by: CodeRabbit <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants