Skip to content

fix: sync URL hash when following same-page search hits - #963

Open
btea wants to merge 2 commits into
nodejs:mainfrom
btea:fix/search-hit-hash
Open

fix: sync URL hash when following same-page search hits#963
btea wants to merge 2 commits into
nodejs:mainfrom
btea:fix/search-hit-hash

Conversation

@btea

@btea btea commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

followSearchHit only called scrollIntoView() for same-page hits, leaving the address bar without a hash (or stuck on a stale one from a previously followed hit). Push the hit's hash via history.pushState before scrolling so the URL always reflects the jumped-to anchor.

rel #955 (comment) cc @avivkeller

Description

Validation

Related Issues

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run node --run test and all tests passed.
  • I have check code formatting with node --run format:check & node --run lint.
  • I've covered new added functionality with unit tests if necessary.

`followSearchHit` only called `scrollIntoView()` for same-page hits,
leaving the address bar without a hash (or stuck on a stale one from a
previously followed hit). Push the hit's hash via `history.pushState`
before scrolling so the URL always reflects the jumped-to anchor.
Copilot AI review requested due to automatic review settings July 31, 2026 00:24
@btea
btea requested a review from a team as a code owner July 31, 2026 00:24
@cursor

cursor Bot commented Jul 31, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Small UX fix in doc search navigation with no auth, data, or API impact.

Overview
Fixes same-page search hits so the address bar updates to the target fragment instead of only scrolling via scrollIntoView.

followSearchHit now closes the modal (unchanged Escape dispatch), waits two animation frames so the modal is gone, then sets window.location.href to the hit link. Same-page targets use the browser’s native fragment navigation (hash, scroll, history); cross-page hits still load normally. The old branch that parsed the URL and manually scrolled by element id is removed.

Reviewed by Cursor Bugbot for commit 7f459f7. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
api-docs-tooling Ready Ready Preview Jul 31, 2026 2:29am

Request Review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.63%. Comparing base (b80958f) to head (7f459f7).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #963   +/-   ##
=======================================
  Coverage   86.63%   86.63%           
=======================================
  Files         195      195           
  Lines       17938    17938           
  Branches     1632     1632           
=======================================
  Hits        15540    15540           
  Misses       2392     2392           
  Partials        6        6           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@btea btea changed the title fix(web): sync URL hash when following same-page search hits fix: sync URL hash when following same-page search hits Jul 31, 2026
Comment thread packages/core/src/generators/web/ui/components/SearchBox/index.jsx Outdated
Copilot AI review requested due to automatic review settings July 31, 2026 02:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

4 participants