ember.js
ember.js copied to clipboard
RouterService forces model to refresh when queryParams unchanged
I have a query param defined in the controller and set it up to refreshModel in the route.
Then I inject the router service to the component and trigger a transition just with a sub-route name(no passing query params).
Expected: Transition is complete. Parent route's model is not reloaded.
Actual: Query param treated as changed which causes a parent route to reload.
Reproduction: https://ember-twiddle.com/efda3c9e57835c987404a8f5968c7579?openFiles=routes.application.js%2C&route=%2Fin
The other interesting thing which appears in the twiddle is that default queryParams are reflected in the URL only after the second router.transitionTo() invocation.
While the Router RFC sheds some light on the default query params semantics it's still unclear how the transtitionTo should behave when no query params are passed in.
This issue is very similar to https://github.com/emberjs/ember.js/issues/15801. It may have the same root cause. However this issue is reproducible without passing any query params to the router.transtionTo()
I've got the similar issue right now. And I found a problem. If your QP default is a null it's always visible as a change for the router which triggers the model reloading. Try to change it to undefined or other, then it should not reload the model.
I know this is just a temporary fix. We need to find the source of the problem
@Exelord actually in the twiddle I have a non-empty string as a default QP value.
I believe that this is addressed now, @chadhietala may be able to confirm.
I've just verified it against [email protected](cause its release notes say: Final stage of the router service RFC (see emberjs/rfcs#95) and the issue seems to be persited.
Here is a repo with reproduction for [email protected] if helpful.
I believe this all stems back to the fact that QPs are mutable in Router.js. I haven't had the time to get back around to doing the big refactor around how QPs are treated. Right now there is a great deal of implicit behavior due to this issue. I'm going to try and get back around to soon, just been busy at work trying to wrap up some things before the end of the year.
is there a work around for this? other than reloading the window.
i tried chasing this down (making sense of the various special cases for transitions originating from the router service) and all i got were some failing tests: https://github.com/emberjs/ember.js/pull/18579
Still facing this issue when using QPs (refreshModel) with router service's transitionTo API. Any help on this?
Using Ember source and CLI: 3.22
Still facing this issue when using QPs (
refreshModel) with router service'stransitionToAPI. Any help on this?Using Ember source and CLI: 3.22
Same issue here
We also ran into this issue. The workaround we are using in the meantime is not to use the QP's default value and always set it to a different value (with the drawback that it always appears in the url).
Still an issue on Ember 4.4.4 and Ember 4.9.2 :cry:
This is terrible, why is this not fixed yet.
@PowerP could you submit a fix? I'll make sure to get it reviewed as soon as possible!
Still an issue on Ember 5.4.1 😭