From 5a2f2eadc63df7aa77056abf7c674eab5a5cc9ba Mon Sep 17 00:00:00 2001 From: System233 Date: Fri, 21 Feb 2025 05:07:02 +0800 Subject: [PATCH 1/2] Revert "Fix settings done button with unsaved changes" This reverts commit e69f27d3193e816c62dc58f0e811932b4d733f9c. --- .changeset/twenty-rice-own.md | 5 ----- webview-ui/src/components/settings/SettingsView.tsx | 7 ++----- 2 files changed, 2 insertions(+), 10 deletions(-) delete mode 100644 .changeset/twenty-rice-own.md diff --git a/.changeset/twenty-rice-own.md b/.changeset/twenty-rice-own.md deleted file mode 100644 index 0c3ccb141a..0000000000 --- a/.changeset/twenty-rice-own.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"roo-cline": patch ---- - -Fix settings done button with unsaved changes diff --git a/webview-ui/src/components/settings/SettingsView.tsx b/webview-ui/src/components/settings/SettingsView.tsx index f4c49b398d..495bf49bd7 100644 --- a/webview-ui/src/components/settings/SettingsView.tsx +++ b/webview-ui/src/components/settings/SettingsView.tsx @@ -173,6 +173,7 @@ const SettingsView = forwardRef(({ onDone }, text: currentApiConfigName, apiConfiguration, }) + // onDone() setChangeDetected(false) } } @@ -216,11 +217,7 @@ 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) + confirmDialogHandler.current?.() } }, []) From 7d58fe76bb733daf91f2fbfdf91da4a906ab0b48 Mon Sep 17 00:00:00 2001 From: System233 Date: Fri, 21 Feb 2025 05:08:58 +0800 Subject: [PATCH 2/2] Fix settings done button with unsaved changes --- webview-ui/src/App.tsx | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/webview-ui/src/App.tsx b/webview-ui/src/App.tsx index 3980f38cc8..3ae441cd52 100644 --- a/webview-ui/src/App.tsx +++ b/webview-ui/src/App.tsx @@ -28,16 +28,13 @@ const App = () => { const [tab, setTab] = useState("chat") const settingsRef = useRef(null) - const switchTab = useCallback( - (newTab: Tab) => { - if (tab === "settings" && settingsRef.current?.checkUnsaveChanges) { - settingsRef.current.checkUnsaveChanges(() => setTab(newTab)) - } else { - setTab(newTab) - } - }, - [tab], - ) + const switchTab = useCallback((newTab: Tab) => { + if (settingsRef.current?.checkUnsaveChanges) { + settingsRef.current.checkUnsaveChanges(() => setTab(newTab)) + } else { + setTab(newTab) + } + }, []) const onMessage = useCallback( (e: MessageEvent) => { @@ -73,7 +70,7 @@ const App = () => { ) : ( <> - {tab === "settings" && switchTab("chat")} />} + {tab === "settings" && setTab("chat")} />} {tab === "history" && switchTab("chat")} />} {tab === "mcp" && switchTab("chat")} />} {tab === "prompts" && switchTab("chat")} />}