Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is RouterService#isActive(someRoute) supposed to entagle with tracking? #19004

Closed
NullVoxPopuli opened this issue Jun 5, 2020 · 2 comments
Closed

Comments

@NullVoxPopuli
Copy link
Contributor

NullVoxPopuli commented Jun 5, 2020

Just noticed that if I have:

@service router;

get isTabActive() {
  return this.router.isActive(this.args.route); // route is static for this scenario
}

isTabActive never updates when the URL changes / a router transition occurs

@NullVoxPopuli NullVoxPopuli changed the title Is <RouterService>.isActive(someRoute) supposed to entagle with tracking? Is RouterService#isActive(someRoute) supposed to entagle with tracking? Jun 5, 2020
@rwjblue
Copy link
Member

rwjblue commented Jun 5, 2020

@NullVoxPopuli - FWIW, I dealt with these exact issues in adopted-ember-addons/ember-router-helpers#263 by just accessing routerService.currentURL and routerService.currentRouteName which do properly entangle things with tracking. Note in that PR there is a minor bit of "trickiness" with regards to checking both .currentURL and .currentRouteName, neither of those fields are "good enough" on their own (because loading states would not change url but would change route name, and changed model values wouldn't change route name but would change URL).

I think it would be good to access those two properties from within isActive to prevent folks from having to do the kinds of work arounds I did in the PR above.

chancancode added a commit that referenced this issue Sep 25, 2020
…onsume-tracked-properties

Resolves #19004: RouterService#isActive() now consumes currentURL and…
NullVoxPopuli added a commit to NullVoxPopuli/ember.js that referenced this issue Sep 27, 2020
NullVoxPopuli added a commit to NullVoxPopuli/ember.js that referenced this issue Sep 27, 2020
rwjblue added a commit that referenced this issue Sep 28, 2020
Backport fix for #19004: RouterService#isActive() now consumes currentURL to 3.20
NullVoxPopuli added a commit to NullVoxPopuli/ember.js that referenced this issue Sep 28, 2020
rwjblue added a commit that referenced this issue Sep 28, 2020
Backport fix for #19004: RouterService#isActive() to beta
@johngibbons
Copy link

@NullVoxPopuli - FWIW, I dealt with these exact issues in rwjblue/ember-router-helpers#263 by just accessing routerService.currentURL and routerService.currentRouteName which do properly entangle things with tracking. Note in that PR there is a minor bit of "trickiness" with regards to checking both .currentURL and .currentRouteName, neither of those fields are "good enough" on their own (because loading states would not change url but would change route name, and changed model values wouldn't change route name but would change URL).

I think it would be good to access those two properties from within isActive to prevent folks from having to do the kinds of work arounds I did in the PR above.

It looks like the merged solution ended up only accessing currentUrl, which does create an issue when transitioning between a parent route's loader to the child route, e.g. accounts.item.campaigns.loading => accounts.item.campaigns.item. A getter based on this route will only fire during the loading phase since the url does not change, and would return false for isActive('accounts.item.campaigns.item') during that phase, even though ultimately it should return true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants