Fix state management of overrides not properly resetting loader; closes #3429
This commit is contained in:
parent
7b429831ce
commit
52588beeb0
1 changed files with 1 additions and 4 deletions
|
@ -13,7 +13,6 @@ export type SettableModalProps = Omit<ModalProps, 'appear' | 'visible' | 'onDism
|
||||||
interface State {
|
interface State {
|
||||||
render: boolean;
|
render: boolean;
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
showSpinnerOverlay?: boolean;
|
|
||||||
propOverrides: Partial<SettableModalProps>;
|
propOverrides: Partial<SettableModalProps>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +30,6 @@ function asModal<P extends {}> (modalProps?: SettableModalProps | ((props: P) =>
|
||||||
this.state = {
|
this.state = {
|
||||||
render: props.visible,
|
render: props.visible,
|
||||||
visible: props.visible,
|
visible: props.visible,
|
||||||
showSpinnerOverlay: undefined,
|
|
||||||
propOverrides: {},
|
propOverrides: {},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -39,7 +37,6 @@ function asModal<P extends {}> (modalProps?: SettableModalProps | ((props: P) =>
|
||||||
get computedModalProps (): Readonly<SettableModalProps & { visible: boolean }> {
|
get computedModalProps (): Readonly<SettableModalProps & { visible: boolean }> {
|
||||||
return {
|
return {
|
||||||
...(typeof modalProps === 'function' ? modalProps(this.props) : modalProps),
|
...(typeof modalProps === 'function' ? modalProps(this.props) : modalProps),
|
||||||
showSpinnerOverlay: this.state.showSpinnerOverlay,
|
|
||||||
...this.state.propOverrides,
|
...this.state.propOverrides,
|
||||||
visible: this.state.visible,
|
visible: this.state.visible,
|
||||||
};
|
};
|
||||||
|
@ -50,7 +47,7 @@ function asModal<P extends {}> (modalProps?: SettableModalProps | ((props: P) =>
|
||||||
*/
|
*/
|
||||||
componentDidUpdate (prevProps: Readonly<P & AsModalProps>, prevState: Readonly<State>) {
|
componentDidUpdate (prevProps: Readonly<P & AsModalProps>, prevState: Readonly<State>) {
|
||||||
if (prevProps.visible && !this.props.visible) {
|
if (prevProps.visible && !this.props.visible) {
|
||||||
this.setState({ visible: false, showSpinnerOverlay: false });
|
this.setState({ visible: false, propOverrides: {} });
|
||||||
} else if (!prevProps.visible && this.props.visible) {
|
} else if (!prevProps.visible && this.props.visible) {
|
||||||
this.setState({ render: true, visible: true });
|
this.setState({ render: true, visible: true });
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue