Cancelling a navigation instruction with a redirect raises inconsistent navigation events
See original GitHub issueI’ve tested the new navigation events (processing
-> success
|error
|canceled
-> compete
) using the routing pipeline steps as described in the documentation, but the new router does not seem to raise consistent events when redirecting from a pipeline step.
When redirecting from /welcome
to /login
in the authorize
pipeline step, the router:navigation:success
and router:navigation:complete
events are fired with the /welcome
instruction, no other events are raised in regards to the redirection/navigation to /login
, but the redirection does happen (original example in PR https://github.com/aurelia/router/pull/97).
This causes issues when components subscribe to these events to change their appearance/behaviour, because the application ends up onto the /login
page correctly, but the components receive the event telling them they are on the /welcome
page.
This is what I see in the logs when I listen to the events and I log when the redirection happens in my authorize
pipeline step:
processing /welcome
redirect /login
success /welcome
complete /welcome
I’ve tried the same logic but using canActivate
in the welcome
controller, which results in the same outcome above.
canActivate(params) {
return new Redirect("login");
}
In the events’ data received (success
and complete
), the result
is stating that the status
of the navigation is completed
, and the event instruction is /welcome
, while the browser is showing /login
.
From the event handler perspective, there is no way to determine or being notified what the actual final view is, in this case /login
.
As a minor side note, for a cancelled event, result.status
states cancelled
, but the event name is spelled in American English: canceled
.
Issue Analytics
- State:
- Created 8 years ago
- Comments:11 (7 by maintainers)
Any progress on this issue? I have also hit the same wall
@Alexander-Taran It is: just ran into this specific problem.