emberjs / emberjs/router.js

No way to go "back" for URL transitions

Open
#85 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.3k
Forks
159
PR merge metrics
No merged PRs in 30d

Description

A handler can abort a named transition as follows:

``` js
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()`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.