Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

fix(accordion): panel-open class not shown with custom class #4870

Closed
wants to merge 2 commits into from

Conversation

chenyuzhcy
Copy link
Contributor

@icfantv
Copy link
Contributor

icfantv commented Nov 10, 2015

@chenyuzhcy, so unfortunately, we can't use ng-class here. In fact, this is what we used to have elsewhere in our code base (and perhaps even here...I don't remember off hand).

The issue is that the uib-accordion-group directive uses replace: true and Angular has decided to not support reconciling the ng-class issues when using this property.

@icfantv icfantv closed this Nov 10, 2015
@wesleycho
Copy link
Contributor

I don't think we used to use ng-class at all - we did manage to break ng-class support somehow in part due to replace: true being applied.

For reference, here was the prior commit that added the dynamic class addition: 5ee23a4#diff-2c7728e12322ff30329ef487569c9435

@icfantv
Copy link
Contributor

icfantv commented Nov 10, 2015

@chenyuzhcy, here's the link to the angular issue addressing the ng-class issues.

@icfantv
Copy link
Contributor

icfantv commented Nov 10, 2015

@wesleycho, I couldn't remember exactly, only that we've decided to not support it. #4847 from a few days ago says as much.

@icfantv icfantv changed the title fix(accordion): panel-open class not show with custom class fix(accordion): panel-open class not shown with custom class Nov 10, 2015
@wesleycho
Copy link
Contributor

I thought our decision applied to people using ng-class on the accordion-group element?

@icfantv
Copy link
Contributor

icfantv commented Nov 10, 2015

...and not the template used internally....yes. That's totally fair.

@@ -1,4 +1,4 @@
<div class="panel {{panelClass || 'panel-default'}}">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we do want the ng-class to replace the interpolated class, so

<div class="panel" ng-class="panelClass || 'panel-default'">

This is to keep behavior consistent with dynamic class changing.

@wesleycho
Copy link
Contributor

I made the change - thanks for spending the time on this quick fix!

@wesleycho wesleycho closed this in 0917623 Nov 10, 2015
@trickpattyFH20
Copy link
Contributor

I had ng-class being used on an accordion-group element which now breaks after upgrading to the latest release. My workaround is to rewrite my CSS to support ng-class being used on a wrapping parent element.

I believe the ng-class merging should have either been done internally here till Angular releases a fix, or the implementation of ng-class in this directive should have just been avoided in favor of the interpolated class.

will use class={{classes}} workaround instead of ng-class...

@wesleycho
Copy link
Contributor

@trickpattyFH20 you are relying on unsupported behavior in Angular itself with regards to ng-class and directives that use replace: true. See #4172 for details. This abuse of ng-class actually has negative performance ramifications as well

@trickpattyFH20
Copy link
Contributor

@wesleycho wouldn't it be plausible to rework the uibAccordionGroup directive to not use replace:true?

@wesleycho
Copy link
Contributor

That would result in breaking how Bootstrap's CSS works, and all theming libraries.

@trickpattyFH20
Copy link
Contributor

@wesleycho do you have any sources about what is considered "abuse" of ng-class?
I don't think that an aditional interpolated class should be considered abuse.

I could see it as abuse if you parsed attrs.ngClass and recompiled it in the directive...
but why not just avoid all of that and use the interpolated class like before? This seems like a perfectly reasonable workaround to #5695

@wesleycho
Copy link
Contributor

A simpler workaround would be to just do class="{{customClasses()}}" than bloating library code for a situation explicitly not supported by Angular.

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

Successfully merging this pull request may close these issues.

4 participants