-
Notifications
You must be signed in to change notification settings - Fork 51
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
route.action()
should not happen if previous onBeforeLeave
cancels routing
#354
Comments
router navigate()
should not happen if previous onBeforeLeave
cancels routingroute.action()
should not happen if previous onBeforeLeave
cancels routing
A bit of background to explain the current behavior. The way Router currently works is that for every navigation it first resolves the new pathname to a chain of routes, compares the new routes chain with the previous one and renders the diff. The When resolving the parent layout of the new routes chain Router executes all It does make sense to first check if the currently rendered view allows the navigation, before even starting to resolve the new routes chain. Currently that does not happen at the moment. That might require changes to the route resolution flow so that the first parent layout and the full routes chain are resolved following the same rules (they are slightly different now) |
This is tricky, because both If If So there are two kinds of evil here. It seems we ended up with the first one, because the current implementation assumes that having wrong lifecycle callbacks because of tricky As @manolo points out in the description, unnecessary To minimise the DOM work produced by extra router.setRoutes([
{path: '/path', action: (_, commands) =>
commands.render(
async root => {
const element = document.createElement('foo');
root.appendChild(element);
return element;
}
)
}
]); Such a callback would only be called after the chain is fully resolved, i. e.:
|
We have thought through the order of lifecycle callbacks with the team, and concluded that the existing order is good. From the standpoint of saving on client-server round trips, having resolution, which invokes actions, before calling |
It seems that execution of navigation methods in router is out-of-order. The new component to display is computed before event in the previous element is executed, it means that
route.navigate
is always executed, thus the element has been resolved before the method in the previous element might prevent navigation.For Flow views, this is a critical problem because the new view is created before any signal might be sent to the server to prevent navigation.
I set some logs to prototype and this is the order of method calls.
Load the app pointing to categories:
Navigate to reviews:
The text was updated successfully, but these errors were encountered: