File tree Expand file tree Collapse file tree 2 files changed +23
-9
lines changed Expand file tree Collapse file tree 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({
156156 if ( ! React . isValidElement ( header ) || Array . isArray ( header ) ) {
157157 header = collapsible ?
158158 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- } ) ;
165159 } else {
160+ const className = classNames (
161+ this . prefixClass ( 'title' ) , header . props . className
162+ ) ;
166163
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+ }
170172 }
171173
172174 return (
Original file line number Diff line number Diff line change @@ -58,6 +58,18 @@ describe('Panel', function () {
5858 assert . equal ( header . firstChild . firstChild . innerHTML , 'Heading' ) ;
5959 } ) ;
6060
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+
6173 it ( 'Should have footer' , function ( ) {
6274 let instance = ReactTestUtils . renderIntoDocument (
6375 < Panel footer = "Footer" > Panel content</ Panel >
You can’t perform that action at this time.
0 commit comments