|
@@ -157,9 +157,9 @@ class Modal extends BaseComponent<ModalReactProps, ModalState> {
|
|
|
notifyClose: () => {
|
|
notifyClose: () => {
|
|
|
this.props.afterClose();
|
|
this.props.afterClose();
|
|
|
},
|
|
},
|
|
|
- toggleHidden: (hidden: boolean) => {
|
|
|
|
|
|
|
+ toggleHidden: (hidden: boolean, callback?: (hidden: boolean) => void) => {
|
|
|
if (hidden !== this.state.hidden) {
|
|
if (hidden !== this.state.hidden) {
|
|
|
- this.setState({ hidden });
|
|
|
|
|
|
|
+ this.setState({ hidden }, callback || noop);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
notifyFullScreen: (isFullScreen: boolean) => {
|
|
notifyFullScreen: (isFullScreen: boolean) => {
|
|
@@ -173,17 +173,11 @@ class Modal extends BaseComponent<ModalReactProps, ModalState> {
|
|
|
static getDerivedStateFromProps(props: ModalReactProps, prevState: ModalState) {
|
|
static getDerivedStateFromProps(props: ModalReactProps, prevState: ModalState) {
|
|
|
const newState: Partial<ModalState> = {};
|
|
const newState: Partial<ModalState> = {};
|
|
|
|
|
|
|
|
- if (props.visible && prevState.hidden) {
|
|
|
|
|
- newState.hidden = false;
|
|
|
|
|
- }
|
|
|
|
|
if (props.fullScreen !== prevState.isFullScreen) {
|
|
if (props.fullScreen !== prevState.isFullScreen) {
|
|
|
newState.isFullScreen = props.fullScreen;
|
|
newState.isFullScreen = props.fullScreen;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // if not using animation, need to update hidden state from props
|
|
|
|
|
- if (!props.visible && !props.motion && !prevState.hidden) {
|
|
|
|
|
- newState.hidden = true;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
return newState;
|
|
return newState;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -244,6 +238,10 @@ class Modal extends BaseComponent<ModalReactProps, ModalState> {
|
|
|
if (prevProps.visible && !this.props.visible) {
|
|
if (prevProps.visible && !this.props.visible) {
|
|
|
this.foundation.afterHide();
|
|
this.foundation.afterHide();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if(!this.props.motion){
|
|
|
|
|
+ this.updateHiddenState();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
componentWillUnmount() {
|
|
@@ -260,6 +258,16 @@ class Modal extends BaseComponent<ModalReactProps, ModalState> {
|
|
|
this.foundation.handleOk(e);
|
|
this.foundation.handleOk(e);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ updateHiddenState=()=>{
|
|
|
|
|
+ const {visible}=this.props;
|
|
|
|
|
+ const {hidden}=this.state;
|
|
|
|
|
+ if (!visible && !hidden) {
|
|
|
|
|
+ this.foundation.toggleHidden(true, () => this.foundation.afterClose());
|
|
|
|
|
+ } else if (visible && this.state.hidden) {
|
|
|
|
|
+ this.foundation.toggleHidden(false)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
renderFooter = (): ReactNode => {
|
|
renderFooter = (): ReactNode => {
|
|
|
const {
|
|
const {
|
|
|
okText,
|
|
okText,
|
|
@@ -351,7 +359,7 @@ class Modal extends BaseComponent<ModalReactProps, ModalState> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const classList = cls(className, {
|
|
const classList = cls(className, {
|
|
|
- [`${cssClasses.DIALOG}-displayNone`]: keepDOM && this.state.hidden,
|
|
|
|
|
|
|
+ [`${cssClasses.DIALOG}-displayNone`]: keepDOM && this.state.hidden && !visible,
|
|
|
});
|
|
});
|
|
|
const contentClassName = motion ? cls({
|
|
const contentClassName = motion ? cls({
|
|
|
[`${cssClasses.DIALOG}-content-animate-hide`]: !visible,
|
|
[`${cssClasses.DIALOG}-content-animate-hide`]: !visible,
|
|
@@ -362,18 +370,6 @@ class Modal extends BaseComponent<ModalReactProps, ModalState> {
|
|
|
[`${cssClasses.DIALOG}-mask-animate-show`]: visible
|
|
[`${cssClasses.DIALOG}-mask-animate-show`]: visible
|
|
|
}) : null;
|
|
}) : null;
|
|
|
|
|
|
|
|
- const updateHiddenState=()=>{
|
|
|
|
|
- if (!visible && !this.state.hidden) {
|
|
|
|
|
- this.foundation.toggleHidden(true)
|
|
|
|
|
- } else if (visible && this.state.hidden) {
|
|
|
|
|
- this.foundation.toggleHidden(false)
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- if(!motion){
|
|
|
|
|
- updateHiddenState()
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
return (
|
|
return (
|
|
|
<Portal style={wrapperStyle} getPopupContainer={getPopupContainer}>
|
|
<Portal style={wrapperStyle} getPopupContainer={getPopupContainer}>
|
|
|
<ModalContent
|
|
<ModalContent
|
|
@@ -387,7 +383,7 @@ class Modal extends BaseComponent<ModalReactProps, ModalState> {
|
|
|
style={style}
|
|
style={style}
|
|
|
ref={this.modalRef}
|
|
ref={this.modalRef}
|
|
|
onAnimationEnd={() => {
|
|
onAnimationEnd={() => {
|
|
|
- updateHiddenState();
|
|
|
|
|
|
|
+ this.updateHiddenState();
|
|
|
}}
|
|
}}
|
|
|
footer={renderFooter}
|
|
footer={renderFooter}
|
|
|
onClose={this.handleCancel}
|
|
onClose={this.handleCancel}
|