Skip to content

Page/Loaders revalidation resets Blocker's state #13439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
iammola opened this issue Apr 21, 2025 · 0 comments
Open

Page/Loaders revalidation resets Blocker's state #13439

iammola opened this issue Apr 21, 2025 · 0 comments

Comments

@iammola
Copy link

iammola commented Apr 21, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants