mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 20:09:08 +08:00
1. 折叠器组件增加组件展开和组件收起事件; 2. 折叠器组件增加展开和收起特性动作;
This commit is contained in:
parent
2496428d7a
commit
c0867f16d4
@ -123,10 +123,14 @@ export class Collapse extends React.Component<CollapseProps, CollapseState> {
|
||||
return;
|
||||
}
|
||||
|
||||
this.props.onCollapse?.(this.props, targetState);
|
||||
this.setState({
|
||||
collapsed: targetState
|
||||
});
|
||||
this.setState(
|
||||
{
|
||||
collapsed: targetState
|
||||
},
|
||||
() => {
|
||||
this.props.onCollapse?.(this.props, targetState);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
contentDom: any;
|
||||
|
@ -124,6 +124,8 @@ export default class Collapse extends React.Component<CollapseProps, {}> {
|
||||
'size'
|
||||
];
|
||||
|
||||
basicCollapse = React.createRef<any>();
|
||||
|
||||
@autobind
|
||||
async handleCollapseChange(props: any, collapsed: boolean) {
|
||||
const {dispatchEvent, onCollapse} = this.props;
|
||||
@ -149,8 +151,8 @@ export default class Collapse extends React.Component<CollapseProps, {}> {
|
||||
const targetState = action.actionType === 'collapse';
|
||||
this.handleCollapseChange(this.props, targetState);
|
||||
const collapseInstance = (
|
||||
this.refs.basicCollapse as any
|
||||
).getWrappedInstance?.();
|
||||
this.basicCollapse?.current as any
|
||||
)?.getWrappedInstance?.();
|
||||
collapseInstance?.changeCollapsedState?.(targetState);
|
||||
}
|
||||
}
|
||||
@ -194,7 +196,7 @@ export default class Collapse extends React.Component<CollapseProps, {}> {
|
||||
return (
|
||||
<BasicCollapse
|
||||
id={id}
|
||||
ref="basicCollapse"
|
||||
ref={this.basicCollapse}
|
||||
classnames={cx}
|
||||
classPrefix={ns}
|
||||
mountOnEnter={mountOnEnter}
|
||||
|
Loading…
Reference in New Issue
Block a user