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

[BUGFIX] Fix transitionTo with scoped aliased queryParam. #18859

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@ember/-internals/routing/lib/system/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ class EmberRouter extends EmberObject {
assert(
`You passed the \`${presentProp}\` query parameter during a transition into ${qp.route.routeName}, please update to ${qp.urlKey}`,
(function() {
if (qp.urlKey === presentProp) {
if (qp.urlKey === presentProp || qp.scopedPropertyName === presentProp) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,40 @@ moduleFor(
});
}

['@test RouterService#transitionTo with aliased query params uses the original provided key also when scoped'](
assert
) {
assert.expect(1);

this.add(
'route:parent',
Route.extend({
router: service(),
beforeModel() {
// in this call `url_sort` will be scoped (`parent.child:url_sort`)
// when passed into `_hydrateUnsuppliedQueryParams`
this.router.transitionTo('parent.child', {
queryParams: { url_sort: 'ASC' },
});
},
})
);

this.add(
'route:parent.child',
Route.extend({
queryParams: {
cont_sort: { as: 'url_sort' },
},
cont_sort: 'ASC',
})
);

return this.visit('/').then(() => {
assert.equal(this.routerService.get('currentURL'), '/child?url_sort=ASC');
});
}

['@test RouterService#transitionTo with application query params when redirecting form a different route'](
assert
) {
Expand Down