-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
replaceWith broken on routing during page load #12824
Comments
We tried the following, which mostly works: Ember.Route.reopen({
redirectTo(transition, route, params) {
if (transition.sequence === 0) {
if (params) { this.replaceWith(route, params);
else { this.replaceWith(route); }
} else {
if (params) { this.transitionTo(route, params);
else { this.transitionTo(route); }
}
}
}); Then I would change my route to // route.foos.index
beforeModel(transition) {
const foos = this.modelFor('foos');
this.redirectTo(transition, 'foos.show', foos[0]);
} This works unless we call |
replaceWith
transitionToThis only happens with HistoryLocation (and possibly only with
|
FYI the same thing happens for |
I'm thinking that we can write tests for this by inspecting |
I found what looks like a better workaround for this issue in case anybody is interested. The So, substituting Also, I've submitted a PR to document it and make it public, so if that goes through then this workaround will be on more solid ground. |
Fixed by tildeio/router.js#197 |
@alexspeller I think something might still be broken here. I'm attempting to do a export default Route.extend({
beforeModel(transition) {
if (!transition.state.queryParams.timeframe) {
this.replaceWith({ queryParams: { timeframe: '24hrs' } });
}
}
} If I make the same export default Controller.extend({
queryParams: ['timeframe'],
timeframe: null,
}); This is on v2.10.0-beta.3 (also tried canary). |
@bgentry - I suspect that the issue you are seeing is query param specific, and would likely justify a separate issue. Would you mind making one? |
Main issue fixed by tildeio/router.js#197 |
Given an app with the following:
You are taken back to Yahoo, not Google.
If I were to change
replaceWith
totransitionTo
, then the problem becomes a new one:/foos/
/foos/one
(correctly)/foos/one
(incorrectly)The text was updated successfully, but these errors were encountered: