Merge pull request #1097 from System233/patch-setting-done

Fix settings done button with unsaved changes
This commit is contained in:
Matt Rubens 2025-02-20 16:26:14 -05:00 • committed by GitHub
commit 259c2195e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 21 deletions

View file

@ -1,5 +0,0 @@
---
"roo-cline": patch
---
Fix settings done button with unsaved changes

View file

@ -28,16 +28,13 @@ const App = () => {
const [tab, setTab] = useState<Tab>("chat")
const settingsRef = useRef<SettingsViewRef>(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 = () => {
<WelcomeView />
) : (
<>
{tab === "settings" && <SettingsView ref={settingsRef} onDone={() => switchTab("chat")} />}
{tab === "settings" && <SettingsView ref={settingsRef} onDone={() => setTab("chat")} />}
{tab === "history" && <HistoryView onDone={() => switchTab("chat")} />}
{tab === "mcp" && <McpView onDone={() => switchTab("chat")} />}
{tab === "prompts" && <PromptsView onDone={() => switchTab("chat")} />}

View file

@ -173,6 +173,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone },
text: currentApiConfigName,
apiConfiguration,
})
// onDone()
setChangeDetected(false)
}
}
@ -216,11 +217,7 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone },
const onConfirmDialogResult = useCallback((confirm: boolean) => {
if (confirm) {
setChangeDetected(false)
// Wait for the change detection to be updated
setTimeout(() => {
confirmDialogHandler.current?.()
}, 100)
confirmDialogHandler.current?.()
}
}, [])