router.js icon indicating copy to clipboard operation
router.js copied to clipboard

No way to go "back" for URL transitions

Open jamesarosen opened this issue 11 years ago • 3 comments

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:

  1. createURLTransition sets transition.previousURL and transition.abort() calls updateURL with previousURL if it's defined
  2. createURLTransition sets transition.previousURL, which afterModel can query and call updateURL as necessary
  3. createURLTransition sets transition.isURLTransition, which afterModel can use to conditionally call window.history.back() after calling transition.abort()

jamesarosen avatar Mar 06 '14 22:03 jamesarosen

I'm doing some issues-gardening 🍀 🌷 and stumbled upon this. Is this still an issue? if not, perhaps it can be closed?

sandstrom avatar Nov 05 '16 11:11 sandstrom

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?

nathanhammond avatar Nov 05 '16 19:11 nathanhammond

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

alexspeller avatar Nov 06 '16 22:11 alexspeller