Skip to content

Page/Loaders revalidation resets Blocker's state #13439

Open
@iammola

Description

@iammola

I'm using React Router as a...

library

Reproduction

https://stackblitz.com/edit/github-vyi8vv4v?file=app%2Froutes%2Fhome.tsx

  • Allow the blocker to prevent navigation
  • Trigger the navigation
  • Revalidate the page

System Info

System:
    OS: macOS 15.4.1
    CPU: (8) arm64 Apple M4
    Memory: 95.95 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 23.11.0 - ~/.nvm/versions/node/v23.11.0/bin/node
    npm: 10.9.2 - ~/.nvm/versions/node/v23.11.0/bin/npm
    pnpm: 10.6.5 - ~/.nvm/versions/node/v23.11.0/bin/pnpm
  Browsers:
    Chrome: 135.0.7049.96
    Safari: 18.4
  npmPackages:
    vite: ^6.2.6 => 6.2.6

Used Package Manager

pnpm

Expected Behavior

I expected the blocker's state to not be reset after the active loaders are completed.

Actual Behavior

The blocker's state is reset to unblocked, so the UI and other parts depending on the state are hidden after.

I've investigated it to be from these lines,

// On a successful navigation we can assume we got through all blockers
// so we can start fresh
let blockers = state.blockers;
if (blockers.size > 0) {
blockers = new Map(blockers);
blockers.forEach((_, k) => blockers.set(k, IDLE_BLOCKER));
}
// Always respect the user flag. Otherwise don't reset on mutation
.

There are cases when shortly before the loaders are completed, the user triggers a navigation that should be blocked. So after the sent requests are fulfilled, the modal is closed, so it's like a flash of content.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions