Skip to content

"ignoreBlocker" is ignored when navigating to external url #4844

@nizans

Description

@nizans

Which project does this relate to?

Router

Describe the bug

ignoreBlocker seems to not work when navigating externally.
useBlocker still blocks when navigating with navigate({ ignoreBlocker: true })

When navigating internally using to - the ignoreBlocker works as expected

<Link to="/foo" ignoreBlocker>ROUTE 1 --- IGNORE BLOCKER</Link>

But when navigating externally using href - the ignoreBlocker is ignored - resulting the browser confirm message to apear.

navigate({
  href: 'https://tanstack.com/',
  ignoreBlocker: true,
  reloadDocument: true,
})

This seems to be the same for when reloadDocument is on or off

Your Example Website or App

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

Steps to Reproduce the Bug or Issue

  1. Set a blocker
  2. navigate to an external link (using href) with ignoreBlocker=true
  3. The navigation is blocked even though ignoreBlocker is on

Expected behavior

Expecting the ignoreBlocker to work the same as it does when the navigation is internal

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.130.9
  • OS: macOS
  • Browser: Chrome
  • Bundler: [e.g. vite]

Additional context

Seems like the navigate fn returns before reaching the history section when the ignoreBlocker is being checked.

https://github.com/TanStack/router/blob/91e404b1e248a93889f8d731cf374a312d00af59/packages/router-core/src/router.ts#L1774C1-L1780C1

the ignoreNextBeforeUnload never get set to true like it does when navigating internally

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