emberjs / emberjs/ember.js

RouterService transitionTo/replaceWith transitions are always aborted when destination has refreshModel queryParams with a default value

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

Description

### 🐞 Describe the Bug
Given a route which has queryParam configured with `refreshModel: true`, and with a default value specified (via an identically property on the controller), attempting to transition to the route via the router service will result in an aborted transition. A new transition seems to be created, but the call site has no visibility of it.

e.g. If the call site looks like this:

```js
await this.router.transitionTo("home");
console.log("Transition complete");
```
the console log will never be written.

Using the deprecated (and under Ember 5.x, removed) routing methods on Controller/Route does not show this issue.

Removing either the default value or the `refreshModel` configuration seems to avoid the problem.

This behaviour makes it very difficult to migrate away from the deprecated Controller/Route transition methods.

### 🔬 Minimal Reproduction

See [this repository](https://github.com/davidtaylorhq/ember-router-service-query-param-demonstration/commit/01061f6e09f6ce85f3c777a7acf1d8e319e2cab2) for a minimal demonstration, including a failing acceptance test.

Verbose logging of the problematic transition via the router service looks like this:
```
Attempting transition to home
Preparing to transition from 'other-page' to 'home'
Starting a refresh transition
Transition #1: home: transition was aborted
Transition #1: detected abort.
Transition #2: Resolved all models on destination route; finalizing transition.
Transitioned into 'home'
Transition #2: TRANSITION COMPLETE.
```

A successful transition using the legacy `Controller.transitionToRoute` looks like this:

```
Attempting transition to home
Preparing to transition from 'other-page' to 'home'
Transition #1: Resolved all models on destination route; finalizing transition.
Transitioned into 'home'
Transition #1: TRANSITION COMPLETE.
Transition completed
```

### 🌍 Environment

Reproduced under Ember 3.28 and 4.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.