File tree 2 files changed +23
-9
lines changed
2 files changed +23
-9
lines changed Original file line number Diff line number Diff line change @@ -156,17 +156,19 @@ const Panel = React.createClass({
156
156
if ( ! React . isValidElement ( header ) || Array . isArray ( header ) ) {
157
157
header = collapsible ?
158
158
this . renderCollapsableTitle ( header ) : header ;
159
- } else if ( collapsible ) {
160
-
161
- header = cloneElement ( header , {
162
- className : classNames ( this . prefixClass ( 'title' ) ) ,
163
- children : this . renderAnchor ( header . props . children )
164
- } ) ;
165
159
} else {
160
+ const className = classNames (
161
+ this . prefixClass ( 'title' ) , header . props . className
162
+ ) ;
166
163
167
- header = cloneElement ( header , {
168
- className : classNames ( this . prefixClass ( 'title' ) )
169
- } ) ;
164
+ if ( collapsible ) {
165
+ header = cloneElement ( header , {
166
+ className,
167
+ children : this . renderAnchor ( header . props . children )
168
+ } ) ;
169
+ } else {
170
+ header = cloneElement ( header , { className} ) ;
171
+ }
170
172
}
171
173
172
174
return (
Original file line number Diff line number Diff line change @@ -58,6 +58,18 @@ describe('Panel', function () {
58
58
assert . equal ( header . firstChild . firstChild . innerHTML , 'Heading' ) ;
59
59
} ) ;
60
60
61
+ it ( 'Should have custom component header with custom class' , function ( ) {
62
+ let header = < h3 className = "custom-class" > Heading</ h3 > ,
63
+ instance = ReactTestUtils . renderIntoDocument (
64
+ < Panel header = { header } > Panel content</ Panel >
65
+ ) ;
66
+ header = ReactTestUtils . findRenderedDOMComponentWithClass ( instance , 'panel-heading' ) . getDOMNode ( ) ;
67
+ assert . equal ( header . firstChild . nodeName , 'H3' ) ;
68
+ assert . ok ( header . firstChild . className . match ( / \b p a n e l - t i t l e \b / ) ) ;
69
+ assert . ok ( header . firstChild . className . match ( / \b c u s t o m - c l a s s \b / ) ) ;
70
+ assert . equal ( header . firstChild . innerHTML , 'Heading' ) ;
71
+ } ) ;
72
+
61
73
it ( 'Should have footer' , function ( ) {
62
74
let instance = ReactTestUtils . renderIntoDocument (
63
75
< Panel footer = "Footer" > Panel content</ Panel >
You can’t perform that action at this time.
0 commit comments