-
-
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
Fix query param stickiness between models in ember-engines #14794
Fix query param stickiness between models in ember-engines #14794
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small thing, but overall this seems good to me. I think using the route name also is in the direction of moving away from controllers. @rwjblue can you review when you have a chance?
|
||
return this.visit('/blog/category/1?type=news').then(() => { | ||
let href = this.element.querySelector('a').href; | ||
assert.equal(href.match(/type=news/), null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change this to just be assert.equal(href, '/blog/category/1337');
? It's easier to follow and will give clearer feedback (IMO) if it breaks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed, I'd much prefer to assert against the value we actually expect...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated this to use .endsWith since full href include port number. Let me know if you need further change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be able to use something like:
let { pathname } = this.element.querySelector('a');
assert.equal(pathname, '/blog/category/1337');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
endsWith
solution didn't work because of not being implemented in phantomjs. pathname
solution also didn't work because of ie9 different implementation. I changed this to indexOf
to simulate endsWith
. Let me know if you guys have better preference.
This is looking good! A few specific issues that we should chat through are:
|
b4328dd
to
f88f247
Compare
}); | ||
} | ||
|
||
['@test query params in customized controllerName have stickiness by default between model'](assert) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we handle scenarios where folks have customized controllerName to specify a controller other than the route's controller is handling their QP's? With this change, I think that use case might break?
@rwjblue I added a test on this and you are correct this change will break queryParam in customized controllerName
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I stand corrected - this change doesn't break custom controllerName
case. There was an error in the way i register the route causing the test to fail. I've updated the setup and now it's passing.
f88f247
to
9e28908
Compare
@rwjblue I added test to cover this scenario and it's passing. Please verify if that is what you have in mind. thanks |
See #14788
Summary:
In ember-engines, query param is sticky between different models (see generated link-to). This is not the behavior outside engine and as specified https://guides.emberjs.com/v2.10.0/routing/query-params/#toc_sticky-query-param-values
This is happening because they share the same cacheKey when controller is used as the prefix.