fix(i18n): preserve cart close button#367
Open
DhruvalBhinsara1 wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
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
innerHTMLassignment 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes #366. Fixes the language toggle regression where translating the cart header replaces the existing
#cart-closebutton 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.jsgit diff --checkvmconfirmingapplyTranslations()andswitchLanguage()preserve the original#cart-closenode while changing the cart title text.python3 -m http.server 8000; verifiedindex.htmlandjs/i18n.jsreturn HTTP 200 and thatindex.htmlloadstranslations.js,i18n.js, andmain.jsin order.Risks / Notes
No dependency changes. The broad repo syntax check
find js data -name '*.js' -print0 | xargs -0 -n1 node --checkstill fails on the existingjs/main.jsduplicatesubtotaldeclaration from #353:That pre-existing checkout issue is handled separately in PR #364, so this PR stays focused on #366.
GitHub Actions note: latest
CI Checksis currentlyaction_requiredbefore 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.