Skip to content

fix(i18n): preserve cart close button#367

Open
DhruvalBhinsara1 wants to merge 2 commits into
PatelHarsh2006:mainfrom
DhruvalBhinsara1:codex/fix-i18n-cart-close
Open

fix(i18n): preserve cart close button#367
DhruvalBhinsara1 wants to merge 2 commits into
PatelHarsh2006:mainfrom
DhruvalBhinsara1:codex/fix-i18n-cart-close

Conversation

@DhruvalBhinsara1
Copy link
Copy Markdown

@DhruvalBhinsara1 DhruvalBhinsara1 commented May 29, 2026

What

Closes #366. Fixes the language toggle regression where translating the cart header replaces the existing #cart-close button node and drops its click listener.

How

Updated applyTranslations() to preserve the existing close button element and only update the cart header text node. The close button lookup is scoped to #cart-header, and the translated cart title is computed once before updating or inserting the text node.

Testing

  • node --check js/i18n.js
  • git diff --check
  • Synthetic DOM regression check with Node vm confirming applyTranslations() and switchLanguage() preserve the original #cart-close node while changing the cart title text.
  • Served locally with python3 -m http.server 8000; verified index.html and js/i18n.js return HTTP 200 and that index.html loads translations.js, i18n.js, and main.js in order.

Risks / Notes

No dependency changes. The broad repo syntax check find js data -name '*.js' -print0 | xargs -0 -n1 node --check still fails on the existing js/main.js duplicate subtotal declaration from #353:

js/main.js:832
  const subtotal = getCartSubtotal();
        ^
SyntaxError: Identifier 'subtotal' has already been declared

That pre-existing checkout issue is handled separately in PR #364, so this PR stays focused on #366.

GitHub Actions note: latest CI Checks is currently action_required before any job starts, and the run has zero jobs listed: https://github.com/PatelHarsh2006/ChaatBazaar/actions/runs/26634013136. This is a pre-execution workflow approval state for the fork PR, not a code test failure.

Copilot AI review requested due to automatic review settings May 29, 2026 11:11
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates cart header translation logic to avoid clobbering existing DOM (e.g., the close button) when applying i18n strings.

Changes:

  • Replaces innerHTML assignment with DOM-safe updates to the cart header title text.
  • Preserves the existing close button element and updates/creates only the text node for the title.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread js/i18n.js
Comment thread js/i18n.js Outdated
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] Language toggle breaks cart sidebar close button

2 participants