Skip to content

Conversation

@hellofanny
Copy link
Contributor

@hellofanny hellofanny commented Jan 21, 2026

What's the purpose of this pull request?

Don't display LocalizationButton if localization flag is not enabled in discovery.config.

How to test it?

  1. Set localization.enabled to false
localization: {
    enabled: false,
    defaultLocale: 'pt-BR',
    ....
  }
  1. Localization button shouldn't appear.
image

Summary by CodeRabbit

  • Refactor
    • Enhanced localization feature control with improved gating logic across navigation components.
    • Localization button now respects combined feature flag and availability conditions before rendering in both desktop and mobile views.
    • Streamlined localization state management with consistent enable/disable checks.

✏️ Tip: You can customize this high-level summary in your review settings.

@hellofanny hellofanny requested a review from a team as a code owner January 21, 2026 00:59
@hellofanny hellofanny requested review from gabpaladino and lucasfp13 and removed request for a team January 21, 2026 00:59
@coderabbitai
Copy link

coderabbitai bot commented Jan 21, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

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.

📝 Walkthrough

Walkthrough

The changes introduce consistent feature flag-based gating for localization functionality by creating a computed isLocalizationEnabled condition that combines the store's localization config setting with the button's display flag. This gating is applied across navigation components and the localization button, with early-return guards added to prevent execution when localization is disabled.

Changes

Cohort / File(s) Summary
Navigation Components
packages/core/src/components/navigation/Navbar/Navbar.tsx, packages/core/src/components/navigation/NavbarSlider/NavbarSlider.tsx
Introduce isLocalizationEnabled computed flag combining storeConfig.localization?.enabled and localizationButton?.shouldDisplayLocalizationButton; replace previous conditional with new flag for consistent gating of LocalizationButton rendering in desktop and mobile contexts.
Localization Components & Hooks
packages/core/src/components/ui/LocalizationButton/LocalizationButton.tsx, packages/core/src/sdk/localization/useLocalizationConfig.tsx
Add runtime guards via early returns when storeConfig.localization?.enabled is falsy, preventing LocalizationButton rendering and short-circuiting localization config hook execution.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

enhancement

Poem

🐰 A whisper through the localization gate,
Where configs dance with buttons' fate,
Early returns guard the way,
Only when enabled, locales play!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: verifying if localization is enabled before displaying the LocalizationButton, which aligns with the changeset's objective and modifications across multiple components.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

@hellofanny hellofanny requested review from lariciamota and lemagnetic and removed request for gabpaladino and lucasfp13 January 21, 2026 01:00
@codesandbox-ci
Copy link

codesandbox-ci bot commented Jan 21, 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.

@hellofanny hellofanny self-assigned this Jan 21, 2026
@renatomaurovtex
Copy link
Contributor

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jan 22, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/core/src/sdk/localization/useLocalizationConfig.tsx`:
- Around line 15-17: The early return in useLocalizationConfig causes a Rules of
Hooks violation by conditionally skipping hooks; remove the top-level return and
instead evaluate config.localization?.enabled inside the useState initializer
(the call to useState at line where state is created) so hooks (useState and
useEffect) execute unconditionally, then after hooks run return undefined or the
Settings value as before; update any conditional logic in the useEffect (the
effect that depends on localization) to no-op when enabled is false. Ensure
references to useState and useEffect in useLocalizationConfig remain in the same
order and only the initializer and effect body check
config.localization?.enabled.

@hellofanny hellofanny merged commit 4ee6996 into feat/multilanguage Jan 22, 2026
5 of 6 checks passed
@hellofanny hellofanny deleted the fix/verify-localization-display-button branch January 22, 2026 15:00
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.

4 participants