Skip to content

Incorrect preload & cause for the root's beforeLoad' arguments when defaultPreload: "intent" #4572

Open
@larrifax

Description

@larrifax

Which project does this relate to?

Router

Describe the bug

With defaultPreload: "intent" set on the router, the preload & cause arguments of the root's beforeLoad are incorrect when hovering Link.

There seems to be multiple things that are wrong here:

  1. After initial load, hovering a Link causes beforeLoad to be triggered on the root with cause: enter - even on a link going to the currently active route. This behavior is inconsistent with the behavior after clicking a link, in which cause: stay is what's reported.
  2. preload: false is always reported for the root's beforeLoad when hovering a Link. I would expect preload: true to be reported on a hover.
  3. Going to a nested route, and then hovering on the link to the same route reports incorrect cause: "enter", preload: false on both the parent and on the nested route.

Your Example Website or App

https://stackblitz.com/edit/github-9xzbqucd?file=src%2Fmain.tsx

Steps to Reproduce the Bug or Issue

Reproduction for 1. above:

  1. Hover the Home and About links.
  2. Observe that the console reports the following:
root beforeLoad enter false        (expected "stay" - or maybe "preload"?)
index beforeLoad enter false      (expected "stay" - or maybe "preload"?)
root beforeLoad enter false        (expected "stay" - or maybe "preload"?)
about beforeLoad preload true
  1. Click the Home link.
  2. Hover the Home link.
  3. Observe that the console reports the following:
root beforeLoad stay false
index beforeLoad stay false

Reproduction for 2. above:

  1. Hover the About link.
  2. Observe that the console reports root beforeLoad enter false (expected preload: true)

Reproduction for 3. above:

  1. Click the Nested link.
  2. Hover the Nested link.
  3. Observe that the console reports the following:
root beforeLoad stay false        (expected `cause: "stay", preload: true` - or maybe `cause: "preload", preload: true`?)
bag beforeLoad enter false       (expected `cause: "stay", preload: true` - or maybe `cause: "preload", preload: true`?)
nested beforeLoad enter false  (expected `cause: "stay", preload: true` - or maybe `cause: "preload", preload: true`?)

Expected behavior

See notes in parentheses in the repro steps.

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.124.0
  • OS: Linux
  • Browser: Chrome
  • Browser Version: 138.0
  • Bundler: vite
  • Bundler Version: 6.3.5

Additional context

Related issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions