emberjs / emberjs/ember.js

[Bug] Unexpected aborted transitions following call to RouterService.transitionTo()

Open
#20,038 4 comments 0 reactions 0 assignees View on GitHub
Routing
Dominant language
TypeScript
Stars
22.6k
Forks
4.2k
Avg merge
3d 12h
Merged PRs (30d)
15

Description

### 🐞 Describe the Bug

Initiating a transition using `` or any deprecated transition method after calling `RouterService.transitionTo()` causes an aborted transition which triggers a full route refresh.

Precondition:
* Parent/child routes with navigation between child routes.
* Parent route must define a queryParams object. The actual query param value is left undefined.

### 🔬 Minimal Reproduction

Repro with tests: https://github.com/mgallag/repro-transition-abort

1. Visit `/parent/child-a/`
2. Click on Transition: "via Service" button
3. Click on any of the other transition buttons or links.

### 😕 Actual Behavior
* App transitions between `parent.child-a`, `parent.child-b`, and `parent.child-c`
* The transition between `parent.child-b` and `parent.child-c` is aborted and a full route transition of `parent.child-c` is performed.
* The `parent` route's model hook is called twice

### 🤔 Expected Behavior
* App transitions between `parent.child-a`, `parent.child-b`, and `parent.child-c`
* Transitions are between child routes only.
* The `parent` route's model hook is only ever called once

### 🌍 Environment

- Ember: 4.2.0
- Node.js/npm: 14.19.1
- OS: Mac OS 11.6.4
- Browser: Chrome 99.0.4844.74

### ➕ Additional Context
* This issue requires that a queryParams object is defined on a router but the query param value is left undefined.
* If a query param value is specified in the URL the issue does not occur
* This issue requires that a RouterService initiated transition is followed by any other method of transitioning between child routes.
* If transitions are exclusively initiated by RouterService the issue does not occur
* If transitions are never initiated by the RouterService the issue does not occur

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.