ember-cli-active-link-wrapper
ember-cli-active-link-wrapper copied to clipboard
Allow setting disabled attribute on active-link
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.
@alexspeller: Any feedback on this one?
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.
Thanks @alexspeller. Will look at adding a test.
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.