-
-
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
TransitionTo with queryParams refreshModel triggers model calls on other routes #15801
Comments
@Boudewijn26 so it appears like in previous versions of ember ( < 2.16.2) The model is only hit once. So the value of 'calls' should always be 1. That is what I am seeing the intended results should be. @Boudewijn26 I did some digging and you are right it is embedded fairly deep and picking a right approach is tough. I see what needs to be done just not sure where to start. |
@Boudewijn26 - Thanks for opening the issue! I'd love to figure this out with you, I think the first step here would be to submit a failing test PR. The tests for the router service around query params are here... |
One thing that I'm not certain of here, is if this is an actual bug in the implementation (thats why a failing test PR would be super helpful) or a bug in the documentation around the router service. This invocation is what concerns me: // from the component in `somewhere.nested` the router service transitionTo invocation is:
this.get('router').transitionTo({
queryParams: {
nestedParam: 'a'
}
}) With the current implementation of the router service, only the specified query params will be used. From the perspective of the implementation, this implicitly means that you are setting What we need to figure out is if the current implementation is wrong (e.g. if the RFC says that we should inherit existing query params) or if the docs are wrong (e.g. that this is expected behavior but not well documented)... |
@rwjblue I did notice in ember-cli version 2.13.3 that the param somewhereParam was cleared so there were never any changes so the model hook was never invoked again. In ember-cli version 2.16.2 I noticed that somwhereParam was held onto causing there to be changes and the model hook being invoked. |
@rwjblue The line in ember-routing I am looking at that I am not entirely sure about is For somwhereParam the default value is null which is expected but should 'somewhereParam' really be set? My idea is that it should be removed from the query params list unless it really has been changed since it is still the default value there is not reason to include it in the list of changes. Perhaps I am not understanding the motivation for it entirely. |
@rwjblue I'll get to work on those tests. For me the expected behavior would be following the implementation of |
Issue: emberjs#15801 Reproduces the case of a refresh due to a queryParam transition in a child route. *Still requires actual fix.*
Issue: emberjs#15801 Reproduces the case of a refresh due to a queryParam transition in a child route. *Still requires actual fix.*
Issue: emberjs#15801 Reproduces the case of a refresh due to a queryParam transition in a child route. *Still requires actual fix.*
Issue: emberjs#15801 Reproduces the case of a refresh due to a queryParam transition in a child route. *Still requires actual fix.*
@rwjblue Sorry to bother you, but this is still open. Would it be possible for you or anyone else to give some pointers on how best to fix this? |
@rwjblue RFCS states that transitionTo and replaceWith should behave as previous methods in |
@rwjblue This bug is currently 50 days old. While I understand effort is currently going to Ember 3.0, I hope we can get this fixed within reasonable time for the LTS releases. |
@rwjblue will this bug be fixed? It makes |
I encountered a similar issue. //controller
queryParams: ['createWith'],
createWith: null
//route
queryParams: {
createWith: {
refreshModel: true
}
}, If I use the router service and call this.router.transitionTo('content-blocks.create', {
queryParams: {
createWith: null
}
});
//or
this.router.transitionTo('content-blocks.create'); the model hook of route 'content-blocks.create' is called twice. I found a temporary workaround: this.router.transitionTo('content-blocks.create', {
queryParams: {
createWith: undefined //this works
}
}); |
@rwjblue can this get some attention? This makes the |
I just came across this bug on Ember 3.3. Using the router service's |
Description
It appears that calling
transitionTo
with queryParams on a nested route can trigger calls to the lower route if that route has arefreshModel: true
on an unchanged queryParam. ReproductionSo I have this setup:
somewhere ->
somewhereParam
withrefreshModel: true
with default nullsomewhere.nested ->
nestedParam
In somewhere.nested I have a component which triggers a transition on the router service where nestedParam is changed. This trigger the model on somewhere to be called and then transitioning through the controller then triggers another call.
Cause
I did some digging and it appears that the call to
route#finalizeQueryParamChange
returns the incorrect values, because thetransition._keepDefaultQueryParams
isn't set. This is set inrouter#transitionTo
, but only after the call. The call does return a promise, sotransition._keepDefaultQueryParams = true
may actually be executed in time, but I found this to be very flaky.I'm more than willing to help fix this, however it is embedded so deeply that I find it difficult to pick the right approach.
The text was updated successfully, but these errors were encountered: