Skip to content

Commit

Permalink
fix(Link): Use currentTransitionStack to enable auto-tracking (#394)
Browse files Browse the repository at this point in the history
`currentURL` appears to update when the transition starts, but not anymore when it has ended. This leads to `isActive` not updating correctly if the `model()` hook is taking too long to load data. The `currentTransitionStack` however is changing in the `routeDidChange` event handler, which ensures that `isActive` (and friends) are updating at the right time.
  • Loading branch information
Turbo87 authored Aug 6, 2020
1 parent 212a41b commit 37319f9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions addon/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default class Link {
*/
get isActive(): boolean {
if (!this._linkManager.isRouterInitialized) return false;
this._linkManager.router.currentURL; // eslint-disable-line @typescript-eslint/no-unused-expressions
this._linkManager.currentTransitionStack; // eslint-disable-line @typescript-eslint/no-unused-expressions
return this._linkManager.router.isActive(...this._routeArgs);
}

Expand All @@ -97,7 +97,7 @@ export default class Link {
*/
get isActiveWithoutQueryParams(): boolean {
if (!this._linkManager.isRouterInitialized) return false;
this._linkManager.router.currentURL; // eslint-disable-line @typescript-eslint/no-unused-expressions
this._linkManager.currentTransitionStack; // eslint-disable-line @typescript-eslint/no-unused-expressions
return this._linkManager.router.isActive(
this.routeName,
// Unfortunately TypeScript is not clever enough to support "rest"
Expand All @@ -114,7 +114,7 @@ export default class Link {
*/
get isActiveWithoutModels(): boolean {
if (!this._linkManager.isRouterInitialized) return false;
this._linkManager.router.currentURL; // eslint-disable-line @typescript-eslint/no-unused-expressions
this._linkManager.currentTransitionStack; // eslint-disable-line @typescript-eslint/no-unused-expressions
return this._linkManager.router.isActive(this.routeName);
}

Expand Down

0 comments on commit 37319f9

Please sign in to comment.