Repository navigation
fix: PLP "Load more products" overwriting list instead of appending - #3305
Conversation
WalkthroughProvider: infinite-scroll reset now depends on a memoized ChangesSearch Content Stability
ProductGrid Spacing
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
|
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. |
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
eduardoformiga
left a comment
There was a problem hiding this comment.
I've tested and it worked as expected.
We must replicate it to the v4.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/ui/src/components/organisms/ProductGrid/styles.scss`:
- Line 34: The stylesheet uses the deprecated CSS property grid-gap in
ProductGrid styles (three occurrences) — replace each grid-gap declaration with
the modern gap property (e.g., change grid-gap:
var(--fs-product-grid-gap-desktop); to gap: var(--fs-product-grid-gap-desktop);)
and update the other responsive occurrences similarly so the grid/flex spacing
uses gap consistently; ensure no other grid-gap instances remain in the same
stylesheet.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: cd395f1f-e82f-42a1-913e-dfd45824f87e
📒 Files selected for processing (1)
packages/ui/src/components/organisms/ProductGrid/styles.scss
| } | ||
|
|
||
| @include media(">=notebook") { | ||
| grid-gap: var(--fs-product-grid-gap-desktop); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify deprecated property usage in SCSS
rg -n '\bgrid-gap\s*:' --type=scss
# Optional lint check for this file
pnpm stylelint packages/ui/src/components/organisms/ProductGrid/styles.scssRepository: vtex/faststore
Length of output: 50654
Replace deprecated grid-gap with gap in responsive styles.
Stylelint flags grid-gap as deprecated at lines 21, 25, and 34. Use the modern gap property for Grid/Flex spacing instead.
Suggested diff
- grid-gap: var(--fs-product-grid-gap-mobile);
+ gap: var(--fs-product-grid-gap-mobile);
`@include` media(">=tablet") {
grid-template-columns: repeat(var(--fs-product-grid-columns-desktop), 1fr);
- grid-gap: var(--fs-product-grid-gap-tablet);
+ gap: var(--fs-product-grid-gap-tablet);
padding-bottom: var(--fs-product-grid-gap-tablet);
}
`@include` media(">=notebook") {
- grid-gap: var(--fs-product-grid-gap-desktop);
+ gap: var(--fs-product-grid-gap-desktop);
padding-bottom: var(--fs-product-grid-gap-desktop);
}🧰 Tools
🪛 Stylelint (17.11.0)
[error] 34-34: Expected "grid-gap" to be "gap" (property-no-deprecated)
(property-no-deprecated)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/ui/src/components/organisms/ProductGrid/styles.scss` at line 34, The
stylesheet uses the deprecated CSS property grid-gap in ProductGrid styles
(three occurrences) — replace each grid-gap declaration with the modern gap
property (e.g., change grid-gap: var(--fs-product-grid-gap-desktop); to gap:
var(--fs-product-grid-gap-desktop);) and update the other responsive occurrences
similarly so the grid/flex spacing uses gap consistently; ensure no other
grid-gap instances remain in the same stylesheet.
@faststore/api
@faststore/cli
@faststore/components
@faststore/core
@faststore/graphql-utils
@faststore/lighthouse
@faststore/sdk
@faststore/ui
commit: |
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
Providerin@faststore/sdkwas resetting the infinite-scrollpagesarray on every URL change reaching<SearchProvider>. Two converging conditions made it fire on a Sentinel-triggered URL update:parseSearchStatealways returns a newselectedFacetsarray reference, even when the content is identical.Sentinelreflects the page in viewport into the URL viarouter.replace('?page=N'). That update bubbles back to theProviderviaasPath, and the effect's referential deps fire, callingresetInfiniteScroll(N), which collapsespagesto[N].How it works?
The
useEffectinpackages/sdk/src/search/Provider.tsxwas split into two with different responsibilities:setState(rest)keeps running on any change toterm,sort,selectedFacets, orpage— preserving the search-context sync introduced in fix: search update #3015.resetInfiniteScrollnow runs only when the content of the search (term/sort/selectedFacets) changes, gated by a stable, content-based key built viaJSON.stringify. Page-only URL updates no longer trigger a reset.rest.pageis 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 setspage: 0), the reset uses the correct page. Aneslint-disablewith a code comment documents the intent.How to test it?
Pre-conditions: any PLP with more than 12 products and "Load more products" enabled.
/<plp>?page=2, the gallery should open directly on page 2 (deep-link still works).Starters Deploy Preview
URL Preview with fix
References
fix: search update) — introduced the dependency-array on theProvidereffect that, combined with theSentinel, caused the regression.Summary by CodeRabbit