emberjs / ember.js

Ember.js - A JavaScript framework for creating ambitious web applications
https://emberjs.com
MIT License
22.47k stars 4.21k forks source link

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

Open mgallag opened 2 years ago

mgallag commented 2 years ago

🐞 Describe the Bug

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

Precondition:

πŸ”¬ 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

πŸ€” Expected Behavior

🌍 Environment

βž• Additional Context

mgallag commented 2 years ago

Potentially related issues: https://github.com/emberjs/ember.js/issues/19611, https://github.com/emberjs/ember.js/issues/16349

RobbieTheWagner commented 2 years ago

Would it be possible to introduce a param to stop this behavior? The refresh method allows us to pass a route name in and only refresh that model and descendants, not parents. https://api.emberjs.com/ember/4.4/classes/RouterService/methods/transitionTo?anchor=refresh

dwickern commented 2 years ago

This is caused by https://github.com/emberjs/ember.js/issues/19493. The router redirects to the new query params which aborts the original transition.

I applied my workaround to your repro and all tests pass. Upgrading to ember 4.4 should also fix it.

nickschot commented 8 months ago

I don't know when this came back (or if it was ever truly fixed), but I just ran into this issue with ember-source 5.6, also related to https://github.com/emberjs/ember.js/issues/20512 . Either using a LinkTo, the private -routing service's transitionTo method or removing the default query parameter value appears to "fix" the issue. None are true solutions I think.