Skip to content

fix(core): drop stale pickupPoint facet on delivery method switch - #3606

Open
caiotheodoro wants to merge 1 commit into
vtex:devfrom
caiotheodoro:fix/stale-pickup-point-facet
Open

caiotheodoro wants to merge 1 commit into
vtex:devfrom
caiotheodoro:fix/stale-pickup-point-facet

Conversation

@caiotheodoro

@caiotheodoro caiotheodoro commented Nov 24, 2026 •

Copy link
Copy Markdown

What's the purpose of this pull request?

onDeliveryFacetChange in useDeliveryPromise drops the selected
pickupPoint facet whenever the shopper switches to a delivery method other
than pickup-in-point. That works on the desktop filter (FilterDesktop,
which goes through setSearchState on a filtered facet list) but not in the
mobile filter drawer (FilterSlider, which dispatches toggleFacets against
the full selected list): the cleanup line was a .concat() call whose result
is discarded, so the stale facet never leaves selected.

How it works?

The else branch now collects the currently selected pickupPoint facets and,
when filterDispatch is set, pushes them into facetsToToggle so the reducer
toggles them off — mirroring how the pickup-in-point branch pushes the
pickupPoint facet to toggle it on. The non-dispatch path is unchanged: the
filtered currentSelectedFacets list already excludes pickupPoint facets.

Before this fix, switching to "delivery" left {pickupPoint: <id>} selected,
which kept the pickup-in-point radio looking selected next to "delivery" and,
if the shopper toggled back to pickup-in-point, removed the pickup point from
the URL entirely (shipping=pickup-in-point with no pickupPoint).

How to test it?

  • New tests in
    test/sdk/deliveryPromise/useDeliveryPromise.browser.test.tsx replay the
    dispatched action through the real toggleFacets reducer logic:
    • switching to delivery drops pickupPoint from selected;
    • toggling back to pickup-in-point restores pickup-in-point +
      pickupPoint instead of losing the point.
  • pnpm vitest run test/sdk/deliveryPromise — 28/28 pass.
  • Manual: on a store with deliveryPromise.enabled, pick a pickup point, open
    the filter slider, select another delivery method — pickup-in-point should
    no longer stay selected, and toggling back keeps the pickup point.

References

Fixes #3605.

packages/core/src/sdk/deliveryPromise/useDeliveryPromise.ts,
packages/core/src/components/search/Filter/FilterSlider.tsx.

onDeliveryFacetChange computed the pickupPoint cleanup for the
filterDispatch path but discarded the result of Array.prototype.concat,
which is non-mutating. In the filter slider (FilterSlider) the stale
pickupPoint facet stayed in selected: the pickup-in-point radio kept
rendering as selected next to the new method, and toggling back to
pickup-in-point dropped the chosen pickup point from the URL entirely.

Push the selected pickupPoint facets into facetsToToggle when dispatching
so the reducer toggles them off, matching the non-dispatch path.
@caiotheodoro
caiotheodoro requested a review from a team as a code owner November 24, 2026 00:02
@caiotheodoro
caiotheodoro requested review from eduardoformiga and lemagnetic and removed request for a team November 24, 2026 00:02

@orca-security-us orca-security-us Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed OSS Licenses high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Malicious Packages high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

@sonar-workflows

Copy link
Copy Markdown

@dk-pr-review

dk-pr-review Bot commented Nov 24, 2026

Copy link
Copy Markdown

DK Review — Audit Summary

Verdict: ✅ CLEAN

Severity Count
BLOCK 0
RESTRICT 0
SUGGEST 0

Scenarios evaluated: feature-flags, general-review
Scenarios skipped: dependency-governance (no matching files), pipeline-config (no matching files), agent-skills-review (no matching files), quality-ratchet (no matching files)


📋 Findings (0)

No findings.


DK Review v1.0.0 | To contest a finding, reply in its thread

This branch has not been deployed

No deployments
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.

Filter slider keeps a stale pickupPoint facet when switching delivery methods

1 participant