Skip to content

🐛 fix(navbar): fix layout shift on language toggle#259

Merged
lwinmoepaing merged 1 commit intomyanmar-software-engineers:mainfrom
myothuko98:fix/navbar-layout-shift
Mar 22, 2026
Merged

🐛 fix(navbar): fix layout shift on language toggle#259
lwinmoepaing merged 1 commit intomyanmar-software-engineers:mainfrom
myothuko98:fix/navbar-layout-shift

Conversation

@myothuko98
Copy link
Copy Markdown
Contributor

@myothuko98 myothuko98 commented Mar 22, 2026

🎯 Summary

Fixed navbar menu item widths and sign-in button width changing size
when switching between English and Myanmar languages, causing visible
layout shifts on each toggle.

Resolved by locking each nav item to a fixed width via a
desktopNavWidthByKey map and enforcing whitespace-nowrap + inline-flex
layout on all nav links and the sign-in button.

📋 What Changed

src/components/Common/Navbar/Navbar.tsx
src/components/Auth/SignInButton.tsx

Features / Fixes

  • ✅ Fixed-width map (desktopNavWidthByKey) locks each nav item regardless of translated label length
  • inline-flex justify-center whitespace-nowrap on NavLink prevents text-driven width changes
  • min-w + whitespace-nowrap on SignInButton for stable width across locales
  • ✅ Fixed React purity issue: replaced Math.random() in render with static sparkleDriftX constant
  • ✅ Refined desktop nav gap, letter-spacing, and font size for visual balance

🎮 How It Works

  1. User opens any page with the navbar visible
  2. Clicks the language toggle (EN ↔ MM)
  3. Nav items and sign-in button maintain identical dimensions
  4. No layout shift or reflow occurs on toggle

✅ Testing Checklist

  • Toggle language between EN and MM
  • Verify all nav item widths remain stable
  • Verify sign-in button width remains stable
  • Verify nav is readable and balanced in both locales
  • Verify no TypeScript / lint errors
  • Verify Myanmar font renders correctly without clipping

Work of Validation

menu-width.mp4

Issue #255

Navbar menu item widths and sign-in button width were changing size
when switching between English and Myanmar languages, causing layout
instability.

- Add `desktopNavWidthByKey` fixed-width map to lock each nav item
  to a stable Tailwind width class regardless of translated label length
- Apply `inline-flex justify-center whitespace-nowrap` on nav links
  to prevent text-driven width changes
- Add `min-w` and `whitespace-nowrap` to `SignInButton` for stable
  width across locales
- Fix React purity issue: replace `Math.random()` in render with
  static `sparkleDriftX` constant array
- Refine desktop nav spacing, gap, and font size for visual balance
@myothuko98 myothuko98 closed this Mar 22, 2026
@myothuko98 myothuko98 reopened this Mar 22, 2026
Copy link
Copy Markdown
Member

@lwinmoepaing lwinmoepaing left a comment

Choose a reason for hiding this comment

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

LGTM 💯

@lwinmoepaing lwinmoepaing linked an issue Mar 22, 2026 that may be closed by this pull request
2 tasks
@lwinmoepaing lwinmoepaing merged commit eebdfac into myanmar-software-engineers:main Mar 22, 2026
4 checks passed
@myothuko98 myothuko98 deleted the fix/navbar-layout-shift branch March 22, 2026 12:30
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.

[Bug]: Navbar items layout shifting on language change

2 participants