Skip to content

Conversation

@mgramigna
Copy link

We have a use case where we only want to block navigation if you are navigating away from a specific "root path".

E.g. /a/b -> /a/c is ok, but /a/b -> /d is not

This PR allows you to define a function instead of just a boolean for determining if the blocker should activate, where nextLocation is passed in to that callback function

Putting this in draft to start as I'm unsure what to do about handling navigation.back(), couldn't see an obvious way to peek the previous location of the router and pass it through

@netlify
Copy link

netlify bot commented Jan 15, 2026

Deploy Preview for cedarjs canceled.

Name Link
🔨 Latest commit bee91bc
🔍 Latest deploy log https://app.netlify.com/projects/cedarjs/deploys/696930ad0efc700007bb6285

Comment on lines +71 to +72
// FIXME: for navigating back, we don't have the next location info
processBlockers(0, performBack, '')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tobbe any thoughts on a sensible approach here when we're going back? Don't see an obvious way to access the previous location to pass in to the callback

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant