1. 折叠器组件增加组件展开和组件收起事件; 2. 折叠器组件增加展开和收起特性动作;

This commit is contained in:
wangyuzhen01 2023-08-22 11:10:50 +08:00
parent 2496428d7a
commit c0867f16d4
2 changed files with 13 additions and 7 deletions

View File

@ -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;

View File

@ -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}