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 #18268 query param options not being read #18269

Merged
merged 5 commits into from
Nov 14, 2021
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
9 changes: 8 additions & 1 deletion packages/@ember/-internals/routing/lib/system/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,14 @@ class Route extends EmberObject.extend(ActionHandler, Evented) implements IRoute
@property _optionsForQueryParam
*/
_optionsForQueryParam(qp: QueryParam) {
return get(this, `queryParams.${qp.urlKey}`) || get(this, `queryParams.${qp.prop}`) || {};
const queryParams = get(this, 'queryParams');
return (
get(queryParams, qp.urlKey) ||
get(queryParams, qp.prop) ||
queryParams[qp.urlKey] ||
queryParams[qp.prop] ||
{}
);
}

/**
Expand Down
31 changes: 31 additions & 0 deletions packages/@ember/-internals/routing/tests/system/route_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,37 @@ moduleFor(
runDestroy(owner);
}

['@test _optionsForQueryParam should work with nested properties'](assert) {
let route = EmberRoute.extend({
queryParams: {
'nested.foo': {
// By default, controller query param properties don't
// cause a full transition when they are changed, but
// rather only cause the URL to update. Setting
// `refreshModel` to true will cause an "in-place"
// transition to occur, whereby the model hooks for
// this route (and any child routes) will re-fire, allowing
// you to reload models (e.g., from the server) using the
// updated query param values.
refreshModel: true,

// By default, the query param URL key is the same name as
// the controller property name. Use `as` to specify a
// different URL key.
as: 'foobar',
},
},
}).create();

assert.strictEqual(
route._optionsForQueryParam({
prop: 'nested.foo',
urlKey: 'foobar',
}),
route.queryParams['nested.foo']
);
}

["@test modelFor doesn't require the routerMicrolib"](assert) {
let route = EmberRoute.create({
_router: { _routerMicrolib: null },
Expand Down