Skip to content

Commit 4c9f14e

Browse files
justinparkmichael-s-molina
authored andcommitted
fix(explore): verified props is not updated (#31008)
(cherry picked from commit 9e5b568)
1 parent 7911ccc commit 4c9f14e

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

superset-frontend/src/explore/components/controls/withAsyncVerification.tsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
import { JsonArray, JsonValue, t } from '@superset-ui/core';
2525
import { ControlProps } from 'src/explore/components/Control';
2626
import builtInControlComponents from 'src/explore/components/controls';
27+
import useEffectEvent from 'src/hooks/useEffectEvent';
2728

2829
/**
2930
* Full control component map.
@@ -72,7 +73,7 @@ export type AsyncVerify = (
7273
* Whether the extra props will update the original props.
7374
*/
7475
function hasUpdates(
75-
props: ControlPropsWithExtras,
76+
props: Partial<ControlPropsWithExtras>,
7677
newProps: ExtraControlProps,
7778
) {
7879
return (
@@ -165,17 +166,17 @@ export default function withAsyncVerification({
165166
[basicOnChange, otherProps, verifiedProps],
166167
);
167168

168-
useEffect(() => {
169-
if (needAsyncVerification && verify) {
169+
const verifyProps = useEffectEvent(
170+
(verifyFunc: AsyncVerify, props: typeof otherProps) => {
170171
if (showLoadingState) {
171172
setIsLoading(true);
172173
}
173-
verify(otherProps)
174+
verifyFunc(props)
174175
.then(updatedProps => {
175176
if (showLoadingState) {
176177
setIsLoading(false);
177178
}
178-
if (updatedProps && hasUpdates(otherProps, updatedProps)) {
179+
if (updatedProps && hasUpdates(verifiedProps, updatedProps)) {
179180
setVerifiedProps({
180181
// save isLoading in combination with other props to avoid
181182
// rendering twice.
@@ -198,14 +199,14 @@ export default function withAsyncVerification({
198199
);
199200
}
200201
});
202+
},
203+
);
204+
205+
useEffect(() => {
206+
if (needAsyncVerification && verify) {
207+
verifyProps(verify, otherProps);
201208
}
202-
}, [
203-
needAsyncVerification,
204-
showLoadingState,
205-
verify,
206-
otherProps,
207-
addWarningToast,
208-
]);
209+
}, [needAsyncVerification, verify, otherProps, verifyProps]);
209210

210211
return (
211212
<ControlComponent

0 commit comments

Comments
 (0)