From 7ecad9977cafa9c9e452797d5800a9911f8cd57a Mon Sep 17 00:00:00 2001 From: Volodymyr Radchenko Date: Thu, 5 Nov 2020 15:46:36 +0200 Subject: [PATCH 1/2] [REPRODUCTION] routeInfo's are lost on intermediate transitions Refs: https://github.com/emberjs/ember.js/issues/14438 --- tests/router_test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/router_test.ts b/tests/router_test.ts index 5a5e7858..42ed9294 100644 --- a/tests/router_test.ts +++ b/tests/router_test.ts @@ -5379,7 +5379,7 @@ scenarios.forEach(function (scenario) { }); test('intermediateTransitionTo() has the correct RouteInfo objects', function (assert) { - assert.expect(5); + assert.expect(6); routes = { application: createHandler('application'), foo: createHandler('foo', { @@ -5400,6 +5400,8 @@ scenarios.forEach(function (scenario) { enteredCount++; } else if (enteredCount === 1) { assert.equal(transition.to!.name, 'loading', 'entering'); + // https://github.com/emberjs/ember.js/issues/14438 + assert.equal(transition[STATE_SYMBOL].routeInfos.length, 2, 'with routeInfos present'); enteredCount++; } else { assert.equal(transition.to!.name, 'foo', 'back to'); From 0be0d19761214b870a4121babd13f2bdcc84e3fa Mon Sep 17 00:00:00 2001 From: Volodymyr Radchenko Date: Wed, 4 Nov 2020 12:48:47 +0200 Subject: [PATCH 2/2] [BUGFIX beta] provide transition to setupContext for internal transitions Prior https://github.com/tildeio/router.js/commit/e792f2c76a5ef03c9a3e548b309cee364dd0138f we were calling `this.setupContext(newState, transition)` for intermediate transitions, which got replaced with `this.setupContexts(newState)`. This results in buggy behavior when query params get lost in certain scenarios. Refs: https://github.com/emberjs/ember.js/issues/14438 --- lib/router/router.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/router/router.ts b/lib/router/router.ts index 5de1b895..00e6c708 100644 --- a/lib/router/router.ts +++ b/lib/router/router.ts @@ -229,9 +229,9 @@ export default abstract class Router { } if (isIntermediate) { - let transition = new InternalTransition(this, undefined, undefined); + let transition = new InternalTransition(this, undefined, newState); this.toReadOnlyInfos(transition, newState); - this.setupContexts(newState); + this.setupContexts(newState, transition); this.routeWillChange(transition); return this.activeTransition!;