Skip to content
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

Fix validation stage redirection behaviour. #197

Commits on Oct 31, 2016

  1. Fix validation stage redirection behaviour.

    This has been broken forever AFAIK, and is surprising to a lot of people. In
    fact, even the ember guides recommend [using `this.transitionTo` for redirecting](https://guides.emberjs.com/v2.9.0/routing/redirection/)
    
    This is in fact broken. If you use `transitionTo` as a redirect strategy,
    then you get an extra history entry if you hit the route as the first route in
    your app. This breaks the back button, as the back button takes you to the route
    with the redirect, then immediately redirects back to the page you're on.
    Maybe you can go back if you hammer back button really quickly, but you have to
    hammer it loads super quick. Not a good UX.
    
    `replaceWith` works if you use it to redirect from a route that's your
    initial transition. However if you use it to redirect and you hit that route
    from some way _after_ the initial app load, then at the point that the
    replaceWith is called, you are still on the same URL. For example, if you are on
    `/` and you click a link to `/foo`, which in it's model hook redirects to `/bar`
    using `replaceWith`, at the time replaceWith is called, your current url is `/`.
    
    This means `/` entry gets removed from your history entirely. Clicking back
    will take you back to whatever page you were on before `/`, which often isn't
    event your app, maybe it's google or something. This breaks the back button
    again.
    
    This commit should do the correct thing in all cases, allowing replaceWith and
    transitionTo outside of redirects as specified by the developer but only allowing
    transitionTo or replaceWith in redirects in a way that doesn't break the back
    button.
    alexspeller committed Oct 31, 2016
    6 Configuration menu
    Copy the full SHA
    3723643 View commit details
    Browse the repository at this point in the history