Skip to content

fix: simplify city and postal code display logic in RegionBar and RegionButton - #3259

Merged
eduardoformiga merged 2 commits into
mainfrom
fix/show-zip-code
Apr 7, 2026
Merged

eduardoformiga merged 2 commits into
mainfrom
fix/show-zip-code

Conversation

@eduardoformiga

@eduardoformiga eduardoformiga commented Apr 6, 2026 •

Copy link
Copy Markdown
Member

What's the purpose of this pull request?

Show the zip code even if city is empty from validate session API.

How it works?

After typing the ZIP code 50610290 and clicking "Apply":

  • The modal closed.
  • The session was updated with postalCode: "50610290".
  • The button did not update to show the address ❌ — continues displaying "Set your location"

The postal code was saved correctly, but the city returned as an empty string "" from the validateSession API. The condition city && postalCode requires both to be truthy. Since the city is an empty string (""), which is falsy in JavaScript, the condition fails and displays the default label even with the postal code filled.

The same problem exists in the RegionButton (desktop).

The frontend should be resilient to this — displaying at least the postal code when available. I will apply a fix to display only the zip code when the city field is empty.

Before After
beforeApr-06-2026 15-49-03 afterApr-06-2026 15-50-13

Summary by CodeRabbit

  • Bug Fixes
    • Improved location display across region controls: postal codes are shown reliably even when city is missing; city is omitted when absent; punctuation and spacing between city and postal code are now handled correctly to avoid stray commas or missing separators.

…ionButton components

- Updated the logic to conditionally render city and postal code in both RegionBar and RegionButton components.
- Ensured postal code is displayed correctly based on the presence of city, improving clarity in the UI.
@eduardoformiga
eduardoformiga requested a review from a team as a code owner April 6, 2026 18:57
@eduardoformiga
eduardoformiga requested review from gabpaladino and renatomaurovtex and removed request for a team April 6, 2026 18:57
@coderabbitai

coderabbitai Bot commented Apr 6, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 76582c93-1f45-442a-9022-b8b1979e1593

📥 Commits

Reviewing files that changed from the base of the PR and between 60cb542 and c25ea52.

📒 Files selected for processing (1)
  • packages/components/src/molecules/RegionBar/RegionBar.tsx

Walkthrough

RegionBar and RegionButton rendering logic was changed to display postal code whenever postalCode is truthy and format city/postal combinations conditionally. City is now optional; postal code can render alone or with a preceding comma when city is present.

Changes

Cohort / File(s) Summary
Regional Display Components
packages/components/src/molecules/RegionBar/RegionBar.tsx, packages/core/src/components/region/RegionButton/RegionButton.tsx
Refactored conditional rendering so postalCode drives display. City rendering is conditional; postal code renders alone if city is absent, or with a leading ", " when city is present. Fallbacks remain tied to absence of postalCode.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

📬 Postal codes step forward, bold and lone,
City may whisper, or stay unknown,
Conditionals trimmed, commas placed with care,
Small UI changes, tidy and fair. ✨

🚥 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 accurately summarizes the main change: simplifying conditional logic for city and postal code display in two components (RegionBar and RegionButton).

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/show-zip-code

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

codesandbox-ci Bot commented Apr 6, 2026 •

Copy link
Copy Markdown

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/components/src/molecules/RegionBar/RegionBar.tsx`:
- Around line 101-114: The RegionBar renders a location container whenever
postalCode is truthy, but if postalCode exists while shouldDisplayPostalCode is
false and city is empty it produces an empty block; update the render logic in
RegionBar (the JSX that checks postalCode, city, and shouldDisplayPostalCode) to
only render the <div data-fs-region-bar-location> when there will actually be
visible text (i.e., when city is non-empty or shouldDisplayPostalCode is true),
or provide a fallback label when both are missing, so that postalCode,
shouldDisplayPostalCode and city conditions are combined to avoid an empty
element.
🪄 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: a807baf6-3bbb-4980-b3f9-0ef64de8714d

📥 Commits

Reviewing files that changed from the base of the PR and between 4cef440 and 60cb542.

📒 Files selected for processing (2)
  • packages/components/src/molecules/RegionBar/RegionBar.tsx
  • packages/core/src/components/region/RegionButton/RegionButton.tsx

…ar component

- Updated the logic to ensure postal code is displayed only when city is present or when it should be displayed, improving the clarity of the location information in the UI.
@eduardoformiga
eduardoformiga merged commit 8944bee into main Apr 7, 2026
6 checks passed
@eduardoformiga
eduardoformiga deleted the fix/show-zip-code branch April 7, 2026 19:22
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.

2 participants