Repository navigation
fix: localization selector stale and reset selection for unsaved changes - #3301
Conversation
WalkthroughAdds session-driven synchronization to useBindingSelector (two useEffect hooks), a user-edited guard preventing session overwrites, a public reset() to re-enable syncing and restore session values, and calls reset() when the LocalizationSelector is closed. ChangesSession State Synchronization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
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 docstrings
🧪 Generate unit tests (beta)
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. |
6c7ef8e to
4d4ac3a
Compare
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/core/src/sdk/localization/useBindingSelector.ts`:
- Around line 80-88: The effects always overwrite local selection when session
updates (clobbering in-progress user choices); update the two useEffect blocks
(the ones calling setLocaleCode(currentLocale ?? null) and
setCurrencyCode(currentCurrency?.code ?? null)) to only write when the local
state is empty/uninitialized or actually different and not user-modified—e.g.,
check the existing localeCode/currencyCode and only call setLocaleCode or
setCurrencyCode if localeCode is null/undefined (or different and not flagged as
user-chosen), or introduce a simple "initialized" or "userEdited" flag to
prevent overwriting user selections when useSession() resolves late. Ensure you
reference and use the existing symbols localeCode, currencyCode, setLocaleCode,
setCurrencyCode, currentLocale, and currentCurrency?.code in your guard logic.
🪄 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: 76fb1491-5f59-4b1c-9fed-b53aac9b8f72
📒 Files selected for processing (1)
packages/core/src/sdk/localization/useBindingSelector.ts
@faststore/api
@faststore/cli
@faststore/components
@faststore/core
@faststore/diagnostics
@faststore/lighthouse
@faststore/sdk
@faststore/ui
commit: |
## 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]>
Summary by CodeRabbit
Bug Fixes
New Features
What to test
Localization Selector Language display
bug-selected-language-fixed.mov
Reset selection for unsaved changes
reset-selection-selector.mov
Reference:
Jira task