From 84617948853b3f2b99ddb2425ed6e2be6009b0de Mon Sep 17 00:00:00 2001 From: Jonas Metzener Date: Wed, 2 Feb 2022 09:07:20 +0100 Subject: [PATCH] fix(linked-items): don't transition to index route --- addon/components/-private/linked-list-item.js | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/addon/components/-private/linked-list-item.js b/addon/components/-private/linked-list-item.js index 01079b34..4f3f2041 100644 --- a/addon/components/-private/linked-list-item.js +++ b/addon/components/-private/linked-list-item.js @@ -62,7 +62,15 @@ export default class LinkedListItemComponent extends Component { if (!routeInfo) return null; - return { routeInfo, dynamicSegments: getParams(routeInfo) }; + return { + name: routeInfo.name.replace(/\.index$/, ""), + args: [ + ...getParams(routeInfo), + ...(Object.keys(routeInfo.queryParams) + ? [{ queryParams: routeInfo.queryParams }] + : []), + ], + }; } get active() { @@ -70,11 +78,9 @@ export default class LinkedListItemComponent extends Component { return this.args.active ?? false; } - const { routeInfo, dynamicSegments } = this.route; + const { name, args } = this.route; - return this.router.isActive(routeInfo.name, ...dynamicSegments, { - queryParams: routeInfo.queryParams, - }); + return this.router.isActive(name, ...args); } @action @@ -84,10 +90,8 @@ export default class LinkedListItemComponent extends Component { if (typeof this.args.onClick === "function") { this.args.onClick(...[event, this.href].filter(Boolean)); } else if (this.route) { - const { routeInfo, dynamicSegments } = this.route; - this.router.transitionTo(routeInfo.name, ...dynamicSegments, { - queryParams: routeInfo.queryParams, - }); + const { name, args } = this.route; + this.router.transitionTo(name, ...args); } } }