router.js
router.js copied to clipboard
No way to go "back" for URL transitions
A handler can abort a named transition as follows:
afterModel: function(foo, transition) {
if (foo.isInvalid()) { transition.abort(); }
}
The router will not transition to the new route and will not call updateURL. All is good.
Unfortunately, for a URL transition, calling transition.abort() leaves the page in an inconsistent state. The router is acting because handleURL was called, which means the page is already at the new location (e.g. window.location.href has changed).
I'd really like some way of getting the page back to a consistent state. Some ideas:
createURLTransitionsetstransition.previousURLandtransition.abort()callsupdateURLwithpreviousURLif it's definedcreateURLTransitionsetstransition.previousURL, whichafterModelcan query and callupdateURLas necessarycreateURLTransitionsetstransition.isURLTransition, whichafterModelcan use to conditionally callwindow.history.back()after callingtransition.abort()
I'm doing some issues-gardening 🍀 🌷 and stumbled upon this. Is this still an issue? if not, perhaps it can be closed?
Considering the reporter (hi @jamesarosen!) I suspect that this likely was an issue. Given the report and my knowledge of how the sausage gets made This seems like it could reasonably still be an issue. However, it's entirely possible that @alexspeller's recent PR #197 addressed this.
Maybe someone can try to repro now?
So I haven't looked into this in detail but I'd be extremely surprised if my changes made any difference to this particular case