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

Allow setting disabled attribute on active-link #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jcowley
Copy link

@jcowley jcowley commented Jun 4, 2016

I'm using a computed property to disable a child link. The computed property gets set asynchronously when the model loads. When that happens, I get the dreaded "You modified *** twice in a single render" deprecation warning:

DEPRECATION: You modified (-join-classes "ember-view" (-normalize-class "_active" _active 
activeClass=undefined inactiveClass=undefined) (-normalize-class "_disabled" _disabled 
activeClass=undefined inactiveClass=undefined) (-normalize-class "_transitioningIn" _transitioningIn 
activeClass=undefined inactiveClass=undefined) (-normalize-class "_transitioningOut" _transitioningOut 
activeClass=undefined inactiveClass=undefined) (-normalize-class "disabled" disabled 
activeClass=undefined inactiveClass=undefined)) twice in a single render. This was unreliable in Ember 
1.x and will be removed in Ember 3.0 [deprecation id: ember-views.render-double-modify]

I believe this is occurring because the child link 'disabled' class gets applied, then ember-cli-active-link-wrapper kicks in and applies the 'disabled' class to the wrapper element. I could of course set {{active-link disabledClass=false}} to prevent this; however, I need the wrapper element to have the 'disabled' class applied so that it disables the bootstrap nav item.

This PR doesn't directly address the underlying issue of the double modification. All it does is allow for setting the disabled attribute on {{active-link}} itself rather than letting it be set dynamically based on the state of the children. Users can then manually disable the wrapper element.

For me, this fixes the double render issue because I can set my computed property directly on {{active-link}} so only one modification occurs during render.

@jcowley
Copy link
Author

jcowley commented Jun 17, 2016

@alexspeller: Any feedback on this one?

@alexspeller
Copy link
Owner

Really sorry I am in the middle of an international move so have been neglecting OS stuff - I'd like to see a test of this before merging but the concept looks OK to me.

@jcowley
Copy link
Author

jcowley commented Jul 6, 2016

Thanks @alexspeller. Will look at adding a test.

@boyanyordanov
Copy link

I've just stumbled upon this, while implementing infinite scroll with ember smoke and mirrors. The list contains models, represented with links wrapped with {{active-link}} and when a model is removed (or unloaded) from the store I get this warning for all items that "smoke and mirrors" has hidden, because they are off screen.

If I can help with something, just let 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 this pull request may close these issues.

3 participants