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 lts] Router service: Failing with query parameters on application controller #18244

Merged
merged 5 commits into from
Oct 30, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 4 additions & 1 deletion packages/@ember/-internals/routing/lib/system/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,10 @@ class EmberRouter extends EmberObject {
return true;
}

if (_fromRouterService && presentProp !== false) {
if (_fromRouterService && presentProp !== false && qp.urlKey !== qp.prop) {
// assumptions (mainly from current transitionTo_test):
// - this is only supposed to be run when there is an alias to a query param and the alias is used to set the param
// - when there is no alias: qp.urlKey == qp.prop
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { run } from '@ember/runloop';
import { get } from '@ember/-internals/metal';
import { RouterTestCase, moduleFor } from 'internal-test-helpers';
import { InternalTransition as Transition } from 'router_js';
import { inject as service } from '@ember/service';

moduleFor(
'Router Service - transitionTo',
Expand Down Expand Up @@ -362,5 +363,31 @@ moduleFor(
}, 'You passed the `cont_sort` query parameter during a transition into parent.child, please update to url_sort');
});
}

['@test RouterService#transitionTo with application query params when redirecting form a different route'](
assert
) {
assert.expect(1);

this.add(
'route:parent.child',
Route.extend({
router: service(),
beforeModel() {
this.router.transitionTo('parent');
},
})
);
this.add(
'controller:parent',
Controller.extend({
queryParams: ['url_sort'],
})
);

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