diff --git a/webview-ui/src/components/settings/SettingsView.tsx b/webview-ui/src/components/settings/SettingsView.tsx index f4c49b398d..034338e301 100644 --- a/webview-ui/src/components/settings/SettingsView.tsx +++ b/webview-ui/src/components/settings/SettingsView.tsx @@ -217,13 +217,16 @@ const SettingsView = forwardRef(({ onDone }, const onConfirmDialogResult = useCallback((confirm: boolean) => { if (confirm) { setChangeDetected(false) - // Wait for the change detection to be updated - setTimeout(() => { - confirmDialogHandler.current?.() - }, 100) } }, []) + useEffect(() => { + if (!isChangeDetected && confirmDialogHandler.current) { + confirmDialogHandler.current(); + confirmDialogHandler.current = undefined; // Clear the handler after execution + } + }, [isChangeDetected]); + const handleResetState = () => { vscode.postMessage({ type: "resetState" }) }