fix(nav): render the wishlist count badge the UI has always tried to update - #1719
Open
MOHITKOURAV01 wants to merge 1 commit into
Open
fix(nav): render the wishlist count badge the UI has always tried to update#1719MOHITKOURAV01 wants to merge 1 commit into
MOHITKOURAV01 wants to merge 1 commit into
Conversation
…update updateWishlistCount() reads the wishlist, looks up #wishlist-badge and returns early when it is missing. That span existed in no markup in the repository, so the early return was taken on every call and the counter never appeared - while the cart badge beside it in the same nav worked. The styling was already shipping: ~30 lines in components.css and a dark-theme rule in base.css, on every page load, for an element that never rendered. Adds the badge to the desktop nav inside a positioning wrapper, mirroring the cart link's structure, and a matching badge to the mobile drawer's Wishlist row where the cart row already had one. The desktop badge's offsets now match #cart-badge so the two counters read as one control surface. updateWishlistCount() was also only ever called from initializeUI(), so the count would have gone stale the moment an item was saved. saveWishlist() is the single choke point every wishlist mutation passes through, so the refresh hangs off it rather than off each call site. Closes AnthropicBots#1714
🔍 Quality Gate Report✅ All quality gates passed!
|
🤖 AI Code Review🔴 Score: 50/100 | AI review unavailable at this time. Automated AI review — a human maintainer will also review. |
|
@MOHITKOURAV01 is attempting to deploy a commit to the Bhuvansh's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
💡 Suggested reviewers based on relevant file history: @Aditya8369, @Pcmhacker-hero |
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 this fixes
Closes #1714
updateWishlistCount()infrontend/scripts/ui.jsis wired intoinitializeUI()right beside the cart counter:…and then returns early on every call, because the element it needs exists in no markup in the repository:
The styling was already shipping — ~30 lines in
components.cssand a dark-theme rule inbase.css, on every page load, for an element that never rendered.What changed
frontend/components/navbar.html.wishlist-icon-wrapperpositioning context, mirroring the.cart-icon-wrapperstructure of the cart link directly below it.#mobile-wishlist-badgeon the drawer's Wishlist row, where the Cart row already had#mobile-cart-badge.frontend/styles/components.css—#wishlist-badgeinherited a bare 5-property rule that assumed normal flow. It now carries the same absolute positioning, offsets, sizing andpointer-events: noneas#cart-badge, plus the wrapper rule it anchors to. Without the wrapper the absolutely positioned badge escapes to the nearest positioned ancestor and lands elsewhere in the nav.frontend/styles/base.css— the dark-theme rule now covers both mobile badges too, which it never did.frontend/scripts/ui.js— updates the mobile badge as well as the desktop one, matching howupdateCartCount()handles its pair.frontend/scripts/utils.js— a second, quieter half of the bug:updateWishlistCount()was only ever called frominitializeUI(), so even with markup the count would go stale the moment an item was saved.saveWishlist()is the single choke point every wishlist mutation passes through, so the refresh hangs off it.Deliberate choices
saveWishlist(), not from each call site. The cart badge takes the other approach — every mutation site remembers to callupdateCartCount()— and that is exactly why the cart count can drift. One choke point cannot be forgotten.typeof window !== "undefined"andtypeof window.updateWishlistCount === "function"), soutils.jsstays usable on pages that do not loadui.js, and in the Node-based tests that require it..mobile-badgefor the drawer rather than adding a second style, so the two drawer rows stay visually identical.pointer-events: noneon the badge, copied from the cart badge, so the counter cannot swallow a click meant for the wishlist link.Tests
New
backend/tests/wishlistBadge.test.js, 17 cases across markup placement (badge inside the wishlist link, not loose in the nav), the accessible label, the positioning contract (asserting the desktop badge'stop/rightmatch#cart-badge's values rather than hardcoding them), dark-mode coverage on both surfaces, and the refresh path including its feature-detection guard.Verified the guard is meaningful: with the frontend changes reverted and only the test applied, 13 of the 17 fail. With the fix in place all 17 pass.
check-a11y-landmarkspasses (31 page(s)), and theappUtilsExports/ a11y / asset suites are green at 238 tests —utils.jspicking up a new call did not change its export surface.Scope
One nav component, two stylesheets, two scripts, one new test file. No backend, route or schema changes.
CI note
Syntax check is red on this branch, and on every open PR in the repo right now. The single failure is inherited from
main:No file this PR touches is implicated —
shop.jsis untouched here. It is tracked as #1696 with a fix open in #1701. Because Syntax check gates the rest of the workflow, Backend tests and Server boots reportskippingrather than running; both suites pass locally on this branch.The red Vercel check is the repo-wide
Authorization required to deploy(teambhuvanshs-projects) and is unrelated to this change.