emberjs / emberjs/ember.js

Child routes cannot re-use param names of parent routes

Open
#17,159 6 comments 0 reactions 0 assignees View on GitHub
Has Reproduction Needs Bug Verification Routing
Dominant language
TypeScript
Stars
22.6k
Forks
4.2k
Avg merge
3d 12h
Merged PRs (30d)
15

Description

The following is either a bug in behavior or a bug in the sense that we are missing an assertion on a key constraint of the router.

Twiddle: https://ember-twiddle.com/84ca6381ddc9ed65dffe9916a102e7f0?openFiles=twiddle.json%2C&route=%2Fparent%2F1%2Fchild%2F1

## Setup

```js
this.route('parent', { path: 'parent/:id' }, function() {
this.route('child', { path: 'child/:id' });
});
```

```hbs
{{#link-to 'parent.child' '1' '2'}} Go to 'parent/1/child/2' {{/link-to}}
```

### Expected Outcome

- `link-to` points to the url `/parent/1/child/2`
- `id` param given to parent is `1`
- `id` param given to child is `2`
- `url` after transitioning is updated to `/parent/1/child/2`

### Observed Outcome

- [BUG] `link-to` points to the url `/parent/2/child/2`
- `id` param given to parent is `1`
- `id` param given to child is `2`
- [BUG] `url` after transitioning is updated to `/parent/1/child/1`

*Note that the urls are different in both places, the bug is inconsistent as to which `id` is accidentally used for both params.

## Versions Affected

All versions of Ember seem to be affected.

Debugging I've found this has been either a bug or an un-asserted constraint since at least Ember `2.12`.

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.