From 50ad0dc54cca602d9c385460b083266d83e65e69 Mon Sep 17 00:00:00 2001 From: MadCcc <1075746765@qq.com> Date: Fri, 8 Apr 2022 16:58:25 +0800 Subject: [PATCH] Revert "fix: 31039 (#215)" This reverts commit a9d2a528e1fe6f7e6c0e8d8037f71f99724194f4. --- src/Panel.tsx | 33 ++++++++++----------------------- tests/index.spec.tsx | 13 ------------- 2 files changed, 10 insertions(+), 36 deletions(-) diff --git a/src/Panel.tsx b/src/Panel.tsx index 4b3391a..d831507 100644 --- a/src/Panel.tsx +++ b/src/Panel.tsx @@ -54,11 +54,10 @@ class CollapsePanel extends React.Component { } = this.props; const disabled = collapsible === 'disabled'; - const collapsibleHeader = collapsible === 'header'; const headerCls = classNames(`${prefixCls}-header`, { [headerClass]: headerClass, - [`${prefixCls}-header-collapsible-only`]: collapsibleHeader, + [`${prefixCls}-header-collapsible-only`]: collapsible === 'header', }); const itemCls = classNames( { @@ -70,36 +69,24 @@ class CollapsePanel extends React.Component { ); let icon: any = ; - - /** header 节点属性 */ - const headerProps: React.HTMLAttributes = { - className: headerCls, - 'aria-expanded': isActive, - onKeyPress: this.handleKeyPress, - }; - if (showArrow && typeof expandIcon === 'function') { icon = expandIcon(this.props); } - if (collapsibleHeader) { - icon = ( - this.handleItemClick()}> - {icon} - - ); - } else { - headerProps.onClick = this.handleItemClick; - headerProps.role = accordion ? 'tab' : 'button'; - headerProps.tabIndex = disabled ? -1 : 0; - } const ifExtraExist = extra !== null && extra !== undefined && typeof extra !== 'boolean'; return (
-
+
collapsible !== 'header' && this.handleItemClick()} + role={accordion ? 'tab' : 'button'} + tabIndex={disabled ? -1 : 0} + aria-expanded={isActive} + onKeyPress={this.handleKeyPress} + > {showArrow && icon} - {collapsibleHeader ? ( + {collapsible === 'header' ? ( {header} diff --git a/tests/index.spec.tsx b/tests/index.spec.tsx index 5637f13..d4673bf 100644 --- a/tests/index.spec.tsx +++ b/tests/index.spec.tsx @@ -545,18 +545,5 @@ describe('collapse', () => { collapse.find('.rc-collapse-header').simulate('click'); expect(collapse.find('.rc-collapse-item-active').length).toBe(0); }); - - it('icon trigger when collapsible equal header', () => { - const collapse = mount( - - - first - - , - ); - - collapse.find('.rc-collapse-header .arrow').simulate('click'); - expect(collapse.find('.rc-collapse-item-active').length).toBe(1); - }); }); });