Skip to content

fix(web): give the English flag icon unique clipPath ids (#1079) - #1080

Merged
JOY (JOY) merged 1 commit into
devfrom
fix/flag-clip-ids
Oct 25, 2026
Merged

JOY (JOY) merged 1 commit into
devfrom
fix/flag-clip-ids

Conversation

@JOY

@JOY JOY (JOY) commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1079

What

LocaleSwitcher is rendered twice in the navbar (phone and desktop). On English pages the current-locale flag is the English SVG, whose <clipPath> ids were hard-coded (flag-en-s, flag-en-t), so both ids appeared twice and each copy's url(#...) resolved to the first one in the document. FlagEN now derives the ids from useId.

Scope note: the duplicates appear on /en/* pages (the English flag is only drawn as the current-locale flag there, or in an open dropdown), not on Vietnamese pages as the issue first said.

Test

  • New e2e/unique-ids.spec.ts: no duplicate ids on /en and /en/smartphones.
  • Mutation check: with LocaleSwitcher.tsx reverted to origin/dev, both tests fail listing flag-en-s and flag-en-t; with the fix, both pass.
  • Live rendering before the fix was visually correct in Chromium (checked with a 4x screenshot of the visible flag); this change keeps the same markup and only renames the ids.

🤖 Generated with Claude Code


📌 TL;DR

This PR fixes a DOM accessibility and rendering bug where the LocaleSwitcher component rendered duplicate SVG clipPath IDs, causing visual glitches when the component appeared multiple times on a page. It introduces React's useId hook to generate unique identifiers for the English flag SVG and adds an E2E test to prevent future ID collisions.

🎯 Type of Change

  • 🚀 New feature
  • 🐛 Bugfix
  • 🧹 Refactor
  • ⚡ Performance
  • 📚 Documentation
  • ⚙️ CI / Configuration

🔍 Changes Walkthrough

File Summary of Changes
apps/web/src/components/elementary/LocaleSwitcher.tsx Refactored the FlagEN component to use React's useId hook. This replaces hardcoded clipPath IDs (flag-en-s, flag-en-t) with dynamic, unique IDs, ensuring that multiple instances of the flag on the same page do not conflict or reference the wrong SVG paths.
apps/web/e2e/unique-ids.spec.ts Added a new Playwright E2E test suite. It navigates to /en and /en/smartphones, scans the DOM for any duplicate id attributes, and asserts that no duplicates exist, specifically guarding against the regression described in #1079.

📊 Architectural Flow

sequenceDiagram
    participant Browser
    participant React
    participant DOM

    Note over Browser,DOM: Page Load (/en)
    
    Browser->>React: Render LocaleSwitcher (Mobile)
    React->>React: Call useId() -> "r1"
    React->>DOM: Insert SVG with clipPath id="r1s"
    
    Browser->>React: Render LocaleSwitcher (Desktop)
    React->>React: Call useId() -> "r2"
    React->>DOM: Insert SVG with clipPath id="r2s"
    
    Note over DOM: No duplicate IDs
    DOM-->>Browser: Render complete
    
    Note over Browser: E2E Test Execution
    Browser->>DOM: Query all [id] elements
    DOM-->>Browser: Return list of IDs
    Browser->>Browser: Check for duplicates
    Browser-->>Browser: Assert duplicates == []
Loading

Summary by CodeRabbit

  • Bug Fixes
    • Locale switcher flag graphics now use unique identifiers, preventing conflicts when multiple instances appear on a page.
  • Tests
    • Added checks for successful loading of the English home and smartphones pages, visible navigation, and duplicate identifiers. These checks help catch page rendering and accessibility-related issues.

The navbar renders the locale switcher twice, so the fixed flag-en-s and
flag-en-t clipPath ids were duplicated on every English page. Derive
them from useId per instance.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JOY JOY (JOY) added the agent:brand Claimed by Agent: Brand label Oct 25, 2026

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

@vercel

vercel Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
rate Ready Ready Preview Oct 25, 2026 4:45pm UTC

Request Review

@github-actions github-actions Bot added the area:frontend Frontend / Next.js / UI label Oct 25, 2026
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d3b868e2-fa32-4b6d-ab60-1da13281afe4
Commits

Reviewing files that changed from the base of the PR and between ecc4c06 and 6d73b3d.

Files selected for processing: 2
  • apps/web/e2e/unique-ids.spec.ts
  • apps/web/src/components/elementary/LocaleSwitcher.tsx

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

FlagEN now generates instance-specific clip-path IDs. A Playwright test checks response status, navigation visibility, and duplicate document IDs on /en and /en/smartphones.

Changes: Unique English flag IDs

Layer / File(s) Summary
Generate and validate unique flag IDs
apps/web/src/components/elementary/LocaleSwitcher.tsx, apps/web/e2e/unique-ids.spec.ts
FlagEN uses useId for clip-path IDs and their SVG references. The Playwright test checks both English routes for successful responses, visible navigation, and duplicate document IDs.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested labels: area:frontend

Suggested reviewers: dos

Merge Risk: Minimal · up to 6d73b

No actionable merge-blocking defect is established.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: assigning unique clipPath IDs to the English flag icon.
Description check Passed The description explains what changed, why it changed, affected files, test coverage, regression validation, and change type. It does not include the template checklist or Notes section, but the core …
Linked Issues check Passed Issue #1079 has two coding requirements. (1) Unique per-instance clipPath ids for the English flag, derived with useId. The head diff of apps/web/src/components/elementary/LocaleSwitcher.tsx adds useI…
Out of Scope Changes check Passed The whole-PR diff against the merge base changes two files. LocaleSwitcher.tsx changes only the FlagEN component and the React import. The markup, viewBox, styles, and paths are unchanged, and only th…
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Full details: Description check

Explanation

The description explains what changed, why it changed, affected files, test coverage, regression validation, and change type. It does not include the template checklist or Notes section, but the core information is complete.

Full details: Linked Issues check

Explanation

Issue #1079 has two coding requirements. (1) Unique per-instance clipPath ids for the English flag, derived with useId. The head diff of apps/web/src/components/elementary/LocaleSwitcher.tsx adds useId to the React import. FlagEN now calls const clipId = useId() and sets clipPath ids to ${clipId}s and ${clipId}t. Both clipPath references (clipPath={url(#${clipId}s)} and clipPath={url(#${clipId}t)}) use the same generated values. The fixed flag-en-s and flag-en-t ids are gone. (2) An E2E check that asserts no duplicate ids on the home page and /smartphones and fails without the fix. apps/web/e2e/unique-ids.spec.ts visits /en and /en/smartphones. The route tree shows that [locale]/page.tsx is the home page, so /en is the English home page. The test scans all [id] elements and fails on any duplicate. Without the fix, FlagEN renders the fixed ids twice on /en pages, so the test would fail. The PR narrows the reported duplicates to /en/* pages, which matches the code path (FlagEN renders as the current-locale flag only on English pages or in an open dropdown). The useId fix applies to every instance, so it does not depend on that narrowing. The author's mutation check was not re-run in this review. The assessment relies on code reading.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against the merge base changes two files. LocaleSwitcher.tsx changes only the FlagEN component and the React import. The markup, viewBox, styles, and paths are unchanged, and only the id values and their url() references change. The new unique-ids.spec.ts is a Playwright test for the duplicate-id requirement in #1079. Both changes connect directly to the linked issue. No unrelated files or behavior changes appear in the summary or the diffs read.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@JOY
JOY (JOY) merged commit 435b067 into dev Oct 25, 2026
22 checks passed
@JOY
JOY (JOY) deleted the fix/flag-clip-ids branch October 25, 2026 16:51
@JOY JOY (JOY) mentioned this pull request Oct 25, 2026
4 of 6 tasks

This branch was successfully deployed

1 active deployment
Preview — 6d73b3d6 Deployed Oct 25, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:brand Claimed by Agent: Brand area:frontend Frontend / Next.js / UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(web): duplicate clipPath ids in the English flag icon

1 participant