Skip to content

Commit 3dee1c3

Browse files
author
haitaoo
committed
fix(Question): Dealing with Modal not disappearing after closing Question
1 parent 6393560 commit 3dee1c3

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

ui/src/hooks/useReportModal/index.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ const useReportModal = (callback?: () => void) => {
4747
setShow(true);
4848
});
4949
};
50-
50+
const asyncCallback = () => {
51+
setTimeout(() => {
52+
callback?.();
53+
});
54+
};
5155
const handleRadio = (val) => {
5256
setInvalidState(false);
5357
setContent({
@@ -93,8 +97,8 @@ const useReportModal = (callback?: () => void) => {
9397
close_type: reportType.type,
9498
close_msg: content.value,
9599
}).then(() => {
96-
callback?.();
97100
onClose();
101+
asyncCallback();
98102
});
99103
return;
100104
}
@@ -109,8 +113,8 @@ const useReportModal = (callback?: () => void) => {
109113
msg: t('flag_success', { keyPrefix: 'toast' }),
110114
variant: 'warning',
111115
});
112-
callback?.();
113116
onClose();
117+
asyncCallback();
114118
});
115119
}
116120

@@ -121,8 +125,8 @@ const useReportModal = (callback?: () => void) => {
121125
flagged_type: reportType.type,
122126
id: params.id,
123127
}).then(() => {
124-
callback?.();
125128
onClose();
129+
asyncCallback();
126130
});
127131
}
128132
};

0 commit comments

Comments
 (0)