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

RouterService forces model to refresh when queryParams unchanged #16349

Open
ro0gr opened this issue Mar 9, 2018 · 16 comments
Open

RouterService forces model to refresh when queryParams unchanged #16349

ro0gr opened this issue Mar 9, 2018 · 16 comments

Comments

@ro0gr
Copy link
Contributor

ro0gr commented Mar 9, 2018

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

@ro0gr
Copy link
Contributor Author

ro0gr commented Mar 10, 2018

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.

@ro0gr
Copy link
Contributor Author

ro0gr commented Mar 12, 2018

This issue is very similar to #15801. It may have the same root cause. However this issue is reproducible without passing any query params to the router.transtionTo()

@Exelord
Copy link
Contributor

Exelord commented Mar 15, 2018

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

@ro0gr
Copy link
Contributor Author

ro0gr commented Mar 15, 2018

@Exelord actually in the twiddle I have a non-empty string as a default QP value.

@rwjblue
Copy link
Member

rwjblue commented Dec 8, 2018

I believe that this is addressed now, @chadhietala may be able to confirm.

@ro0gr
Copy link
Contributor Author

ro0gr commented Dec 10, 2018

I've just verified it against ember-source@3.6(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 ember-source@3.6 if helpful.

@chadhietala
Copy link
Contributor

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.

@arun-jerry
Copy link

is there a work around for this? other than reloading the window.

@aaxelb
Copy link
Contributor

aaxelb commented Nov 25, 2019

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: #18579

aaxelb added a commit to aaxelb/ember-osf-web that referenced this issue Jan 8, 2020
on the `view_only` query param, set the `refreshModel` flag to false
(its default). this avoids an open ember bug[1] that refreshes model
hooks unnecessarily.

[1]: emberjs/ember.js#16349
aaxelb added a commit to aaxelb/ember-osf-web that referenced this issue Jan 17, 2020
on the `view_only` query param, set the `refreshModel` flag to false
(its default). this avoids an open ember bug[1] that refreshes model
hooks unnecessarily.

[1]: emberjs/ember.js#16349
@gokatz
Copy link

gokatz commented Dec 15, 2020

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

@algodave
Copy link

algodave commented May 8, 2021

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

Same issue here

@eodb
Copy link

eodb commented Jul 9, 2021

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).

@Techn1x
Copy link

Techn1x commented Dec 21, 2022

Still an issue on Ember 4.4.4 and Ember 4.9.2 😢

@PowerP
Copy link

PowerP commented Aug 15, 2023

This is terrible, why is this not fixed yet.

@locks
Copy link
Contributor

locks commented Aug 15, 2023

@PowerP could you submit a fix? I'll make sure to get it reviewed as soon as possible!

@mkszepp
Copy link
Contributor

mkszepp commented Feb 8, 2024

Still an issue on Ember 5.4.1 😭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests