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

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

Open davidtaylorhq opened this issue 2 years ago • 3 comments

🐞 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:

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 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

davidtaylorhq avatar Jul 28 '23 16:07 davidtaylorhq

May be related to https://github.com/emberjs/ember.js/issues/20038

kategengler avatar Aug 29 '23 16:08 kategengler

Can also be reproduced under Ember 5.6

nickschot avatar Feb 29 '24 14:02 nickschot

I have the same issue but removing the default value (either removing the property, setting it to null or undefined) in the controller does not solve it for me.

Not relying on refreshModel is too big of a change.

I'm not seeing an easy way forward if transitionToRoute is removed.

panthony avatar May 29 '24 15:05 panthony