emberjs / emberjs/ember.js

A 'transitionTo' using the RouterService causes the model to reload when the transition is aborted

Open
#19,611 2 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

When using the routerService.transitionTo method to transition from a child- into a parent route, and the transition is immediately aborted in the child's 'willTransition' method, the Model hook of the child route is called anyhow while no transition is made.
Both child and parent routes have a queryParam with the 'refreshModel: true' option, but are not defined and use their default values.

Note: the root cause of this issue might be same as for issue https://github.com/emberjs/ember.js/issues/16349 but this issue already occurs aborting the transition.

### Reproduction
Use the test Ember App provided in the https://github.com/eodb/ember-abort-transition repository.
It contains the two child- and parent routes as described above.
In the test template, click the first button that will abort the transition using the RouterService and you will notice that the child's model is reloaded (logged).

In the template, there is also a second button using the deprecated controller.transitionToRoute method which does not show this issue.

### Actual Behavior
The transition in the child's 'willTransition' method is aborted and the Model hook of the child route is called.

### Expected Behavior
When a transition is prevented, the Model hook should not be called.

### 🌍 Environment

- Ember: 3.26.1
- Github repository: https://github.com/eodb/ember-abort-transition

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.