mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 10:59:42 +08:00
fix: collapse修复事件动作无效问题
This commit is contained in:
parent
00bcca021b
commit
4b9bfec58a
@ -25,7 +25,7 @@ const collapseStyles: {
|
||||
|
||||
export interface CollapseProps {
|
||||
key?: string;
|
||||
id?: string;
|
||||
collapseId?: string;
|
||||
propKey?: string;
|
||||
mountOnEnter?: boolean;
|
||||
unmountOnExit?: boolean;
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user