Skip to content

Comments

Fix unwanted scroll-to-top on link hover in search results#306

Merged
geoff-maddock merged 2 commits intomainfrom
copilot/fix-search-results-hover-issue
Nov 21, 2025
Merged

Fix unwanted scroll-to-top on link hover in search results#306
geoff-maddock merged 2 commits intomainfrom
copilot/fix-search-results-hover-issue

Conversation

Copy link
Contributor

Copilot AI commented Nov 21, 2025

Hovering over entity links in location cards triggers scroll-to-top due to router preload events being treated as navigation.

Changes

  • src/routes/root.tsx: Subscribe to onBeforeNavigate instead of onResolved for scroll behavior
    • onResolved fires on both navigation and preload (hover with defaultPreload: 'intent')
    • onBeforeNavigate fires only on actual navigation
  • src/__tests__/routes/root-scroll-behavior.test.tsx: Add test verifying preload doesn't trigger scroll
// Before: scrolls on hover due to preload
router.subscribe('onResolved', () => window.scrollTo(0, 0));

// After: scrolls only on navigation
router.subscribe('onBeforeNavigate', () => window.scrollTo(0, 0));

Screenshot

Search page

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • test.api
    • Triggering command: /usr/local/bin/node /usr/local/bin/node --conditions node --conditions development /home/REDACTED/work/arcane-city-frontend/arcane-city-frontend/node_modules/tinypool/dist/entry/process.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Bug on search results page when hovering over location entity</issue_title>
<issue_description>When hovering over the location entity on the search results page in a location card, it automatically scrolls me up the page. I don't want that to happen.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel
Copy link

vercel bot commented Nov 21, 2025

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

Project Deployment Preview Comments Updated (UTC)
arcane-city-frontend Ready Ready Preview Comment Nov 21, 2025 10:09pm

Changed router scroll behavior from onResolved to onBeforeNavigate to only trigger scroll on actual navigation, not on hover intent preloads. Added test to validate fix.

Co-authored-by: geoff-maddock <55493+geoff-maddock@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix bug on search results page when hovering over location entity Fix unwanted scroll-to-top on link hover in search results Nov 21, 2025
Copilot AI requested a review from geoff-maddock November 21, 2025 22:12
@geoff-maddock geoff-maddock marked this pull request as ready for review November 21, 2025 23:25
@geoff-maddock geoff-maddock merged commit 16369ad into main Nov 21, 2025
17 checks passed
@github-actions
Copy link

📦 Build Size Report

@github-actions
Copy link

✅ PR Checks Complete

Tests Status: success
Node.js Version: 20.x
Commit: 6960ed4

All tests in src/__tests__ have been executed.

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 on search results page when hovering over location entity

2 participants