fix(product): give Recently Viewed the container its renderer looks for - #1718
Open
MOHITKOURAV01 wants to merge 1 commit into
Open
fix(product): give Recently Viewed the container its renderer looks for#1718MOHITKOURAV01 wants to merge 1 commit into
MOHITKOURAV01 wants to merge 1 commit into
Conversation
product.js calls loadRecentlyViewedRecommendations() on every product page. That function writes into #recently-viewed-products, and product.html has never declared it - the page has a Related Products section, which is a different feature, and nothing else. getElementById returns null, the renderer returns early, and no Recently Viewed section appears. Nothing throws, so it reads as an absent feature rather than a broken one. The page already loads recently-viewed-store.js, so every product view has been recording history that the page's only consumer could not display. Adds the section before the Recommended strip, matching the markup shape of the sections around it. Also retires the same stale id in home-init.js, which reaches for new-arrivals-products while index.html declares new-arrivals-container. That file is currently loaded by no page - the homepage renders New Arrivals through product-cards-home.js, which resolves the id correctly - so this is inert today and would resurface the moment anyone wired the file up. Closes AnthropicBots#1713
🔍 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 #1713
frontend/scripts/product.js:516callsloadRecentlyViewedRecommendations()on every product page. That renderer writes into#recently-viewed-products:frontend/product.htmlnever declared that id. It has a Related Products section — a different feature — and nothing else. The lookup misses, the function returns, and no Recently Viewed section appears. Nothing throws and nothing logs, so it reads as an absent feature rather than a broken one.The page already loads
recently-viewed-store.js(line 960), so every product view has been recording history that the page's only consumer could not display.What changed
frontend/product.html— adds the Recently Viewed section, placed before the Recommended strip and matching the markup shape of the sections around it (<section>+<h2>+ subtitle +.pro-container). A comment records why the container has to keep that exact id.frontend/scripts/home-init.js— retires a stale id. It reaches fornew-arrivals-productswhileindex.html:202declaresnew-arrivals-container. This is inert today because no HTML page loadshome-init.jsat all; the homepage renders New Arrivals throughproduct-cards-home.js, which resolves the id correctly. Left as-is, the mismatch resurfaces the moment anyone wires the file up, so it now points at the real container.Deliberate choices
#related-products. Related Products and Recently Viewed are different features with different data sources; sharing one container would have the second render overwrite the first.home-init.js. It duplicates a live render path and is loaded by nothing, so deleting it is defensible — but that is a separate judgement call from fixing a silent container mismatch, and it belongs in its own change.Tests
New
backend/tests/homeContainerContracts.test.js, 12 cases pinning the container contract between each page and the scripts it loads: the declared id, the script still being loaded, the renderer still being called, section ordering, the retired stale id, and a per-page sweep that resolves ids against the page plus the sharednavbar/footer/headercomponents it pulls in at runtime.Verified the guard is meaningful: with the frontend changes reverted and only the test applied, 5 of the 12 fail. With the fix in place all 12 pass.
check-a11y-landmarkspasses — the new section carries no heading-order or landmark regression (31 page(s) have a skip link, a main landmark and one h1).npm run check:syntaxis red on this branch, but only onfrontend/scripts/shop.js:2499(Unexpected end of input), which reproduces identically onmainand is tracked as #1696. No file this PR touches is implicated.Scope
One markup section, one id, one new test file. No script logic, backend 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.