ember.js icon indicating copy to clipboard operation
ember.js copied to clipboard

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

Open eodb opened this issue 3 years ago • 2 comments

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

eodb avatar Jun 25 '21 13:06 eodb

I think this may be a dup of https://github.com/emberjs/ember.js/issues/12473

oliverlangan avatar May 02 '22 19:05 oliverlangan

Still happening in 4.3.

oliverlangan avatar May 02 '22 19:05 oliverlangan