From 4b9bfec58ab62502ef6f898e31d190c6c2382a7d Mon Sep 17 00:00:00 2001 From: hongyang03 Date: Fri, 10 Jun 2022 11:37:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20collapse=E4=BF=AE=E5=A4=8D=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=8A=A8=E4=BD=9C=E6=97=A0=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-ui/src/components/Collapse.tsx | 2 +- packages/amis-ui/src/components/CollapseGroup.tsx | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/amis-ui/src/components/Collapse.tsx b/packages/amis-ui/src/components/Collapse.tsx index 7db1a44c6..55d41651d 100644 --- a/packages/amis-ui/src/components/Collapse.tsx +++ b/packages/amis-ui/src/components/Collapse.tsx @@ -25,7 +25,7 @@ const collapseStyles: { export interface CollapseProps { key?: string; - id?: string; + collapseId?: string; propKey?: string; mountOnEnter?: boolean; unmountOnExit?: boolean; diff --git a/packages/amis-ui/src/components/CollapseGroup.tsx b/packages/amis-ui/src/components/CollapseGroup.tsx index 3c7bf5be5..dc60e33c8 100644 --- a/packages/amis-ui/src/components/CollapseGroup.tsx +++ b/packages/amis-ui/src/components/CollapseGroup.tsx @@ -64,7 +64,7 @@ class CollapseGroup extends React.Component< activeKey = []; } else { for (let i = 0; i < activeKey.length; i++) { - if (activeKey[i] === item.id) { + if (activeKey[i] === item.collapseId) { activeKey.splice(i, 1); break; } @@ -72,9 +72,9 @@ class CollapseGroup extends React.Component< } } else { if (this.props.accordion) { - activeKey = [item.id as string]; + activeKey = [item.collapseId as string]; } else { - activeKey.push(item.id as string); + activeKey.push(item.collapseId as string); } } this.setState({ @@ -90,13 +90,13 @@ class CollapseGroup extends React.Component< return children.map((child: React.ReactElement, index: number) => { let props = child.props; - const id = props.propKey || String(index); - const collapsed = this.state.activeKey.indexOf(id) === -1; + const collapseId = props.propKey || String(index); + const collapsed = this.state.activeKey.indexOf(collapseId) === -1; return React.cloneElement(child as any, { ...props, - key: id, - id, + key: collapseId, + collapseId, collapsed, expandIcon: this.props.expandIcon, propsUpdate: true,