Skip to content

Commit

Permalink
fix(linked-items): don't transition to index route
Browse files Browse the repository at this point in the history
  • Loading branch information
anehx committed Feb 2, 2022
1 parent ab5edf9 commit 8461794
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions addon/components/-private/linked-list-item.js
Expand Up @@ -62,19 +62,25 @@ 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() {
if (!this.route || this.args.active !== undefined) {
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
Expand All @@ -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);
}
}
}

0 comments on commit 8461794

Please sign in to comment.