Add click outside functionality to chat model picker and close on session change

This commit is contained in:
2026-04-17 10:48:13 +02:00
parent e368d21128
commit 791af40503

View File

@@ -1841,6 +1841,23 @@ async function regenerateFromIndex(index, overrideUserText = null) {
setIsDbPickerOpen(false)
}, [activeSessionId, activeSidebarMode])
useEffect(() => {
if (!isChatModelPickerOpen) return
const onPointerDown = (event) => {
if (!chatModelPickerRef.current?.contains(event.target)) {
setIsChatModelPickerOpen(false)
}
}
document.addEventListener('mousedown', onPointerDown)
return () => document.removeEventListener('mousedown', onPointerDown)
}, [isChatModelPickerOpen])
useEffect(() => {
setIsChatModelPickerOpen(false)
}, [activeSessionId, activeSidebarMode])
// Persist the scrollTop of the session we are LEAVING (on chat change or when leaving the chat view)
useEffect(() => {
const leavingSessionId = activeSessionId;