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

Commit ca6b177

Browse files
samjulienwesleycho
authored andcommitted
feat(accordion): use attribute for heading insertion
- Change to use `uibAccordionHeader` attribute for insertion point for header transclusion Closes #5324 Closes #5396 BREAKING CHANGE: This changes to use the `uibAccordionHeader` attribute instead of a `<span>` element for inserting the custom header HTML. If you use a custom template for the accordion group, please add this attribute to the appropriate location.
1 parent a5aebda commit ca6b177

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/accordion/accordion.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,9 @@ angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse'])
123123
link: function(scope, element, attrs, controller) {
124124
scope.$watch(function() { return controller[attrs.uibAccordionTransclude]; }, function(heading) {
125125
if (heading) {
126-
element.find('span').html('');
127-
element.find('span').append(heading);
126+
var elem = angular.element(element[0].querySelector('[uib-accordion-header]'));
127+
elem.html('');
128+
elem.append(heading);
128129
}
129130
});
130131
}

src/accordion/docs/readme.md

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ The body of each accordion group is transcluded into the body of the collapsible
4444

4545
Instead of the `heading` attribute on the `uib-accordion-group`, you can use an `uib-accordion-heading` element inside a group that will be used as the group's header.
4646

47+
If you're using a custom template for the `uib-accordion-group`, you'll need to have an element for the heading to be transcluded into using `uib-accordion-header` (e.g. `<div uib-accordion-header></div>`).
48+
4749
### Known issues
4850

4951
To use clickable elements within the accordion, you have override the accordion-group template to use div elements instead of anchor elements, and add `cursor: pointer` in your CSS. This is due to browsers interpreting anchor elements as the target of any click event, which triggers routing when certain elements such as buttons are nested inside the anchor element.

template/accordion/accordion-group.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="panel" ng-class="panelClass || 'panel-default'">
22
<div role="tab" id="{{::headingId}}" aria-selected="{{isOpen}}" class="panel-heading" ng-keypress="toggleOpen($event)">
33
<h4 class="panel-title">
4-
<a role="button" data-toggle="collapse" href aria-expanded="{{isOpen}}" aria-controls="{{::panelId}}" tabindex="0" class="accordion-toggle" ng-click="toggleOpen()" uib-accordion-transclude="heading"><span ng-class="{'text-muted': isDisabled}">{{heading}}</span></a>
4+
<a role="button" data-toggle="collapse" href aria-expanded="{{isOpen}}" aria-controls="{{::panelId}}" tabindex="0" class="accordion-toggle" ng-click="toggleOpen()" uib-accordion-transclude="heading"><span uib-accordion-header ng-class="{'text-muted': isDisabled}">{{heading}}</span></a>
55
</h4>
66
</div>
77
<div id="{{::panelId}}" aria-labelledby="{{::headingId}}" aria-hidden="{{!isOpen}}" role="tabpanel" class="panel-collapse collapse" uib-collapse="!isOpen">

0 commit comments

Comments
 (0)