Skip to content

fix: preserve locale in LinkButton internal hrefs#3232

Draft
lariciamota wants to merge 2 commits intofeat/multilanguagefrom
fix/login-redirect
Draft

fix: preserve locale in LinkButton internal hrefs#3232
lariciamota wants to merge 2 commits intofeat/multilanguagefrom
fix/login-redirect

Conversation

@lariciamota
Copy link
Contributor

@lariciamota lariciamota commented Feb 26, 2026

What's the purpose of this pull request?

When navigating a store in a non-default locale (e.g., store.com/pt-BR), clicking the Sign In button redirected to /login instead of /pt-BR/login. This caused the store to lose the locale context and render in the default language. The same issue affected any LinkButton in core whose href was a hardcoded internal path.

How it works?

A new locale-aware LinkButton wrapper was created at the core, mirroring the existing Link pattern in core.
The wrapper intercepts the href prop and, for any internal path (starting with /), runs it through resolveLink from useLink. This applies the current locale prefix automatically — whether that's a Next.js locale segment (e.g., /pt-BR/login) or a custom path prefix (e.g., /brasil/login) — while leaving external URLs untouched.
Components updated to use the new wrapper:

  • ButtonSignIn — /login
  • ButtonSignInFallback — /login (Suspense fallback)
  • EmptyGallery — button URLs (comes from CMS)

Going forward, any LinkButton in core should import from src/components/ui/LinkButton instead of @faststore/ui, just as Link is imported from src/components/ui/Link.

How to test it?

  • Run with localization enabled and test a non-default locale (e.g., en-US as default, pt-BR as secondary)
  • Navigate to the store under the secondary locale path (e.g., store.com/pt-BR)
  • Click the Sign In button in the navbar
    Before fix: redirected to /login (default locale, page renders in English)
    After fix: redirected to /pt-BR/login (locale preserved)
    Repeat with a store using a custom path prefix (e.g., /brasil) to verify the custom path is also applied

Starters Deploy Preview

(PR)

References

@lariciamota lariciamota self-assigned this Feb 26, 2026
@lariciamota lariciamota added the bug Something isn't working label Feb 26, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/login-redirect

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

codesandbox-ci bot commented Feb 26, 2026

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.

@lariciamota lariciamota changed the title fix: make login links be locale-aware fix: preserve locale in LinkButton internal hrefs Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant