@@ -54,10 +54,11 @@ class CollapsePanel extends React.Component<CollapsePanelProps, any> {
5454 } = this . props ;
5555
5656 const disabled = collapsible === 'disabled' ;
57+ const collapsibleHeader = collapsible === 'header' ;
5758
5859 const headerCls = classNames ( `${ prefixCls } -header` , {
5960 [ headerClass ] : headerClass ,
60- [ `${ prefixCls } -header-collapsible-only` ] : collapsible === 'header' ,
61+ [ `${ prefixCls } -header-collapsible-only` ] : collapsibleHeader ,
6162 } ) ;
6263 const itemCls = classNames (
6364 {
@@ -69,24 +70,36 @@ class CollapsePanel extends React.Component<CollapsePanelProps, any> {
6970 ) ;
7071
7172 let icon : any = < i className = "arrow" /> ;
73+
74+ /** header 节点属性 */
75+ const headerProps : React . HTMLAttributes < HTMLDivElement > = {
76+ className : headerCls ,
77+ 'aria-expanded' : isActive ,
78+ onKeyPress : this . handleKeyPress ,
79+ } ;
80+
7281 if ( showArrow && typeof expandIcon === 'function' ) {
7382 icon = expandIcon ( this . props ) ;
7483 }
84+ if ( collapsibleHeader ) {
85+ icon = (
86+ < span style = { { cursor : 'pointer' } } onClick = { ( ) => this . handleItemClick ( ) } >
87+ { icon }
88+ </ span >
89+ ) ;
90+ } else {
91+ headerProps . onClick = this . handleItemClick ;
92+ headerProps . role = accordion ? 'tab' : 'button' ;
93+ headerProps . tabIndex = disabled ? - 1 : 0 ;
94+ }
7595
7696 const ifExtraExist = extra !== null && extra !== undefined && typeof extra !== 'boolean' ;
7797
7898 return (
7999 < div className = { itemCls } style = { style } id = { id } >
80- < div
81- className = { headerCls }
82- onClick = { ( ) => collapsible !== 'header' && this . handleItemClick ( ) }
83- role = { accordion ? 'tab' : 'button' }
84- tabIndex = { disabled ? - 1 : 0 }
85- aria-expanded = { isActive }
86- onKeyPress = { this . handleKeyPress }
87- >
100+ < div { ...headerProps } >
88101 { showArrow && icon }
89- { collapsible === 'header' ? (
102+ { collapsibleHeader ? (
90103 < span onClick = { this . handleItemClick } className = { `${ prefixCls } -header-text` } >
91104 { header }
92105 </ span >
0 commit comments