Fix state management of overrides not properly resetting loader; closes #3429

This commit is contained in:
Dane Everitt 2021-09-11 13:24:57 -07:00
parent 7b429831ce
commit 52588beeb0
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53

View file

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