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

Including a loading substate seems to break isActive #42

Closed
chrism opened this issue May 4, 2019 · 3 comments · Fixed by #394
Closed

Including a loading substate seems to break isActive #42

chrism opened this issue May 4, 2019 · 3 comments · Fixed by #394

Comments

@chrism
Copy link

chrism commented May 4, 2019

Hi, thank you for writing this addon.

It seems great and exactly what I need to be able to do conditional classnames like this example which is really handy for functional CSS, like tailwind.

I've encountered what seems like a bug to me, though, when I include a loading substate.

Assuming I have a simple nested route like this...

// routes
stations.js
stations
│   station.js

// templates
stations.hbs
stations
 │   station.hbs

And in my stations.hbs template I set an active link like this:

<Link @route="stations.station" @model={{station.id}} as |l|>
  <a
    href={{l.href}}
    class="{{if l.isActive "active-class"}}"
    {{on "click" l.transitionTo}}
  >
    {{station.name}}
  </a>
</Link>

Then the active-class is displayed as expected.

But, if I introduce a loading substate like this...

// routes
stations.js
stations
│   station.js

// templates
stations.hbs
stations
 │   loading.hbs
 │   station.hbs

Then the active-class is not displayed once the station route has resolved.

Worth noting that this is, I think, due to Ember Data Storefront as I've noticed that if I use findAll and findRecord methods in the models of the routes, instead of Ember Data Storefront's loadRecords and loadRecord, then it does still work.

But on the other hand using the <LinkTo> component still works as expected whichever approach for loading the model data is used.

<LinkTo @route="stations.station" @model={{station.id}} class="">
  {{station.name}}
</LinkTo>

For the moment I'm going to stick with and some non-functional CSS but if this is something you consider a bug then I'd be happy to try to help resolve it.

Thanks.

buschtoens added a commit that referenced this issue May 5, 2019
#42 reminded me, that I got the original idea from EmberMap.
@buschtoens
Copy link
Owner

Yes, I definitely think that this is a bug. Thanks for reporting it!

Worth noting that this is, I think, due to Ember Data Storefront as I've noticed that if I use findAll and findRecord methods in the models of the routes, instead of Ember Data Storefront's loadRecords and loadRecord, then it does still work.

I think this might be because findRecord and findAll potentially resolve immediately, if the records are already in the client's store, whereas the Storefront equivalents always return a Promise, methinks.

Anyhow, I'll try to write a failing test and fix it :)

@buschtoens
Copy link
Owner

Sorry, that it took me over a year... 😅

But 1.2.0 is out and thanks to @Turbo87 it should fix it! 🚀

@chrism
Copy link
Author

chrism commented Aug 6, 2020

no worries @buschtoens just in time to try out on another project!

thanks for letting me know 😄

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

Successfully merging a pull request may close this issue.

2 participants