-
-
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
Bug: updating one query param causes the other QP to reset to its default value #14438
Comments
Do you have a twiddle or repo that we can look at that demonstrates the issue? Based on the special setup circumstances, it is likely that we won't be able to reproduce on our own and a demo would help push this forward... |
Yes, here's the demo: https://ember-twiddle.com/319583e6a61a449259dc5ea1b6133818 |
@lolmaus thank you for the reproduction! |
@lolmaus yeah that is crazy |
I've run into the same issue recently, really surprised me. I've noticed that it doesn't happen when the query params are scoped to the controller:
Unfortunately in my case I really need the default model scoping. Would be great to see this fixed! |
@Serabe @kevinkucharczyk @lolmaus @rwjblue I see that this is still an issue I updated the ember version, v3.4.1, in the twiddle example to confirm. |
Still seems to be a problem on 3.18.1. Here's a fork of the twiddle with that version (and the image removed): |
This is happening because ember.js/packages/@ember/-internals/routing/lib/system/route.ts Lines 975 to 984 in c5bbf86
Which results in The problem is that we're setting ember.js/packages/@ember/-internals/routing/lib/system/route.ts Lines 946 to 953 in c5bbf86
and don't provide any default values on qp creation in ember.js/packages/@ember/-internals/routing/lib/system/route.ts Lines 2343 to 2358 in c5bbf86
@rwjblue @lolmaus Do you have any ideas about what can we do about this? Maybe there's a way to provide default |
…ions Prior tildeio@e792f2c we were calling `this.setupContext(newState, transition)` for intermediate transitions, which got replaced with `this.setupContexts(newState)`. This results in buggy behavior when query params get lost in certain scenarios. Refs: emberjs/ember.js#14438
…ions Prior tildeio@e792f2c we were calling `this.setupContext(newState, transition)` for intermediate transitions, which got replaced with `this.setupContexts(newState)`. This results in buggy behavior when query params get lost in certain scenarios. Refs: emberjs/ember.js#14438
…ions Prior tildeio@e792f2c we were calling `this.setupContext(newState, transition)` for intermediate transitions, which got replaced with `this.setupContexts(newState)`. This results in buggy behavior when query params get lost in certain scenarios. Refs: emberjs/ember.js#14438
Refs: Based off reproduction in emberjs#14438
I found another bug with query params: updating one query param causes the other QP to reset to its default value!
The bug only happens in specific circumstances:
parent
) must have a query param (say,foo
).bar
), either in the same controller or in a child controller.child
route's model hook must return a pending promise.loading
template adjacent to thechild
route.parent
route must be nested under agrandparent
route.grandparent
route must have a dynamic segment.The resulting route structure is:
grandparent
parent
child
(this can be the implicitindex
route)loading
Now, if you update
foo
to a non-default value, then updatingbar
will causefoo
to reset to it's default value!It's crazy, but removing any of the listed prerequisites prevents the bug from manifesting.
Here's a demo: https://ember-twiddle.com/319583e6a61a449259dc5ea1b6133818
I was able to narrow down the issue to this line:
ember.js/packages/ember-routing/lib/system/router.js
Line 830 in 3141f83
When all prerequisites are met and you update
bar
, then pausing execution at that line for thefoo
QP and runningappCache.lookup(cacheKey, qp.prop)
would returnundefined
and, subsequently, causefoo
to reset to its default value. If you remove at least one prerequisite, thenappCache.lookup(cacheKey, qp.prop)
returnsfoo
's current value (expected).Please help. I'm at a loss, I had to finish my work last week but I'm stuck with this. 😭 I've never even heard about
appCache
and I have no idea why it fails.The text was updated successfully, but these errors were encountered: