emberjs / emberjs/ember.js

Sticky Query Params Failing in Engine with Loading Template

Open
#15,051 0 comments 0 reactions 0 assignees View on GitHub
Has Reproduction Query Params Routing
Dominant language
TypeScript
Stars
22.6k
Forks
4.2k
Avg merge
3d 12h
Merged PRs (30d)
15

Description

This PR ended up presenting some issues in my application after updated to `v2.12.0` and Ember-Engines `v0.5.0`: https://github.com/emberjs/ember.js/pull/14794

It does look like this might be an existing and known issue (see https://github.com/emberjs/ember.js/issues/12107) – however, because I am only experiencing this with an Engine and only after upgrading, I figured it was worth opening a new issue.

I've created a failing test that reproduces the issue here: https://github.com/emberjs/ember.js/pull/15050

A quick explanation (this is the same example in the failing test case):

Let's say we have this `routes.js` file in our engine:

```js
this.route('contributor', { path: 'contributor/:id' }, function() {
this.route('posts');
this.route('profile');
});
```

And, our `contributor` controller has a `queryParameter` of `simplified`, which is currently set to the non-default value of `true`.

Also, `contributor/posts` has a slow-loading model and we have a loading template at `contributor/loading.hbs`.

`contributor/posts.hbs` also has a template which contains a link to profile: `{{#link-to "blog.contributor.posts"}}Posts{{/link-to}}`

If we navigate to `contributor/1/posts?simplified=true`, then the link to `blog.contributor.posts` will not contain the `simplified=true` queryParameter as expected.

----

The best I could figure out was that during the `intermediateTransitionTo` (which is the initial transition), the query parameter cache key includes `undefined` when it should contain the `id` of the model for `contributor` (1 in this case).

In fact, the test will pass if we navigate to `contributor/undefined/posts?simplified=true` as it tricks the qpCache key.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.