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

Ember.Controller._calculateCacheKey() failure when routes nested #10838

Closed
amurchick opened this issue Apr 7, 2015 · 7 comments · Fixed by #11535
Closed

Ember.Controller._calculateCacheKey() failure when routes nested #10838

amurchick opened this issue Apr 7, 2015 · 7 comments · Fixed by #11535
Assignees

Comments

@amurchick
Copy link

JSBin example for catch this - http://jsbin.com/zoyoqi#/potatoes/one?filter=filterValue&nextFilter=nextFilterValue

_calculateCacheKey() failure causes incorrect store/restore of nextFilter query parameter in Ember.Controller - if you see on links href's in JSBin example - you will see:

    <a id="ember296" class="ember-view" href="#/badgers/one?nextFilter=nextFilterValue">Badgers</a>
    <a id="ember297" class="ember-view" href="#/badgers/two?nextFilter=nextFilterValue">Badgers</a>
    <a id="ember298" class="ember-view" href="#/bears/one?nextFilter=nextFilterValue">Bears</a>
    <a id="ember299" class="ember-view active" href="#/potatoes/one?filter=filterValue&nextFilter=nextFilterValue">Potatoes</a>

In other words, nextFilter value for route #/potatoes/one sets same for all routes.

However value of filter correctly works as described by http://guides.emberjs.com/v1.11.0/routing/query-params/ in section STICKY QUERY PARAM VALUES.

What leads to failure?
Set breakpoint in http://builds.emberjs.com/beta/ember.debug.js in line 19744:

var value = property_get.get(values, part);

with condition part === "team.tear.tear_menu_id" and after debugger stops - execute line on which debugger stops.

Result: value will be set to undefined, because we are try get team.tear.tear_menu_id, but values contains:

{
    "team.tear": {
        tear_menu_id: "one"
    }
}

Simplest example:

Ember.get({'a.b': {c: 10}}, 'a.b.c')

returns undefined.

@amurchick
Copy link
Author

@rwjblue Do you plan fix this issue?

@trek
Copy link
Member

trek commented Jun 17, 2015

I've been trying to understand what this report is for about 30 minutes now, but am having trouble understanding what you're saying. Can you provide more structure around descriptions of what you're seeing, what you expect to see, and steps to reproduce that limit the code only the portions required to illustrate the issue?

I think you're describing the intended behavior

@trek trek self-assigned this Jun 17, 2015
@rlivsey
Copy link
Contributor

rlivsey commented Jun 17, 2015

If I'm following correctly, I think this is a duplicate / along the same lines as #3638 and #9630

@trek
Copy link
Member

trek commented Jun 18, 2015

@rlivsey that would be an underlying cause of the problem (?), but is really just implementation detail @amurchick uncovered. I'm still trying to figure out what the public API bug is based on the report.

@amurchick
Copy link
Author

@trek I am very accurate describe problem, ok, I will try again...

When the bug occurs?

When you use query parameters in nested routes.

How to produce?

Whats wrong?

For every /:team_menu_id/:tear_menu_id values of query parameter nextFilter are equals.

Why this happens?

Please, see first comment.

What I am expect?

I am expect value of query parameter nextFilterValue will be changed only for /badgers/one, not for all other routes.
For every /:team_menu_id/:tear_menu_id query parameter nextFilter must have own value as described at http://guides.emberjs.com/v1.12.0/routing/query-params/#toc_specifying-query-parameters

There is any case exists, when this worked as described?

Yes, when we do not use nested routes:

E.g., for every /:team_menu_id route - query parameter filter has own value.

@jmurphyau
Copy link
Contributor

Basically the bug is: query params are not sticky on nested routes.

The cacheKey is not being calculated correctly since nested routes have a dot in their name and get doesn't work with keys that have a dot..

@trek I've got a PR that has a failing test and fix but only for query params on controllers not for query params on routes (which is a feature that isn't enabled yet though).. Spent some time trying to figure it out but couldn't manage to and can't spend any more time on it..

I'll push it within the next hr or so

@jmurphyau
Copy link
Contributor

Didn't get a chance to push the PR but I may have got it for route defined query params.. Will push it tomorrow

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

Successfully merging a pull request may close this issue.

4 participants