diff --git a/packages/core/src/SelectCascader/index.tsx b/packages/core/src/SelectCascader/index.tsx index a339cd2b2..aa96df460 100644 --- a/packages/core/src/SelectCascader/index.tsx +++ b/packages/core/src/SelectCascader/index.tsx @@ -35,6 +35,8 @@ export interface SelectCascaderProps { export interface Istate { value: SelectCascaderValue; + modalVisible: boolean; + controlVisible: 'state' | 'props'; } export default class SelectCascader extends Component { @@ -46,14 +48,26 @@ export default class SelectCascader extends Component(), + modalVisible: this.props.visible, + controlVisible: 'props', }; static getDerivedStateFromProps(props: SelectCascaderProps, state: Istate) { - if (JSON.stringify(props.value) === JSON.stringify(state.value)) { + if ( + JSON.stringify(props.value) === JSON.stringify(state.value) && + state.controlVisible === 'props' && + state.modalVisible === props.visible + ) { return null; } + if (JSON.stringify(props.value) === JSON.stringify(state.value)) { + return { + modalVisible: state.controlVisible === 'props' ? props.visible : state.modalVisible, + controlVisible: 'props', + }; + } const getValue = (d: ICascaderDataItem[], val: SelectCascaderValue | undefined) => { let data = d || props.data; let value = val || props.value || props.defaultValue; @@ -70,8 +84,19 @@ export default class SelectCascader extends Component { - maskClosable && this.props.onDismiss?.(); + maskClosable && this.setState({ modalVisible: false, controlVisible: 'state' }); }} > <>