router icon indicating copy to clipboard operation
router copied to clipboard

unexpected committing of search params on hover of the `<Link />` component

Open SeanCassiere opened this issue 3 years ago • 7 comments

Describe the bug

TLDR: When on a route, and you hover on a it commits the search params of the link to the current route, without the user clicking on the link.

When you are currently on a route which has a validateSearch schema configured, hovering a Link that goes back to the same route with differing search params causes the Component/UI to receive the search parameters of the hovered link instead of what is in the URL bar.

NOTE: This behaviour only happens when defaultPreload is set to "intent".

From what I can understand, when the defaultPreload is set intent, on hover (if you are already on the route) then it commits the new search params to the Router's internal state without the user's click/confirmation and does not update the search in the URL.

Your Example Website or App

https://stackblitz.com/edit/tanstack-router-jyvjad?file=src%2Fmain.tsx

Steps to Reproduce the Bug or Issue

  1. Click on the "Page" link in the navbar.
  2. See the printed search params on the page are correctly expected.
  3. Click on the "Home" link in the navbar.
  4. Click on the "Page w/o object search params" link on the home page.
  5. See the printed search params on the page are correctly expected.
  6. Hover on the "Page" link in the navbar.
  7. 💥 See the printed search params have been updated in the UI and are DIFFERENT from what is in the URL bar.

Expected behavior

As a user, when I am on a route and I hover over a link that takes me back to the same route with differing search params, the router should NOT update the current route's search params until the user confirms the navigation with a click.

Screenshots or Videos

Uploaded on Google Drive since screen recording was too large for Github.

Platform

  • OS: macOS
  • Browser: Chrome
  • Browser version: 117
  • Router version: 0.0.1-beta.192

Additional context

No response

SeanCassiere avatar Sep 28 '23 10:09 SeanCassiere

Fixed as of 0.0.1-beta.193

SeanCassiere avatar Sep 28 '23 23:09 SeanCassiere

@SeanCassiere was it actually fixed in .193? I'm still seeing this

JakeHedman avatar Nov 02 '23 13:11 JakeHedman

Try again with the latest release

Tanner Linsley On Nov 2, 2023 at 7:38 AM -0600, Jake Hedman @.***>, wrote:

@SeanCassiere was it actually fixed in .193? I'm still seeing this — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

tannerlinsley avatar Nov 02 '23 22:11 tannerlinsley

Oh wait. This is still an issue. I have a fix locally that I’ll be pushing soon.

Tanner Linsley On Nov 2, 2023 at 7:38 AM -0600, Jake Hedman @.***>, wrote:

@SeanCassiere was it actually fixed in .193? I'm still seeing this — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

tannerlinsley avatar Nov 02 '23 22:11 tannerlinsley

This was working in 193 and then recently broke again. Yesterday I created a new issue https://github.com/TanStack/router/issues/791 for this and then today my colleague sent me a link to this old issue.

mer10z avatar Nov 03 '23 19:11 mer10z

I’m currently re-factoring a lot of things in the router right this second. This issue should be resolved with the release of that refactor

Tanner Linsley On Nov 3, 2023 at 1:28 PM -0600, Luke @.***>, wrote:

This was working in 193 and then recently broke again. Yesterday I created a new issue #791 for this and then today my colleague sent me a link to this old issue. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

tannerlinsley avatar Nov 03 '23 21:11 tannerlinsley

Thanks for the update!

On Fri, Nov 3, 2023 at 22:46 Tanner Linsley @.***> wrote:

I’m currently re-factoring a lot of things in the router right this second. This issue should be resolved with the release of that refactor

Tanner Linsley On Nov 3, 2023 at 1:28 PM -0600, Luke @.***>, wrote:

This was working in 193 and then recently broke again. Yesterday I created a new issue #791 for this and then today my colleague sent me a link to this old issue. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/TanStack/router/issues/749#issuecomment-1793140454, or unsubscribe https://github.com/notifications/unsubscribe-auth/AATGCRYU5K2J57Z3R4EC57DYCVQ2TAVCNFSM6AAAAAA5KXUYDSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJTGE2DANBVGQ . You are receiving this because you commented.Message ID: @.***>

JakeHedman avatar Nov 03 '23 22:11 JakeHedman