Skip to content

Commit

Permalink
Merge pull request #18269 from EWhite613/fix-18268
Browse files Browse the repository at this point in the history
[BUGFIX]  Fix #18268 query param options not being read
  • Loading branch information
ef4 authored Nov 14, 2021
2 parents acdd8ea + 70ddda0 commit 9c9e418
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
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

0 comments on commit 9c9e418

Please sign in to comment.