From 791af40503cef59246dcb79221c8403c29847efe Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Fri, 17 Apr 2026 10:48:13 +0200 Subject: [PATCH] Add click outside functionality to chat model picker and close on session change --- src/App.jsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/App.jsx b/src/App.jsx index 5977d0d..216d7f5 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -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;