From 9ba53807055913c2f3a6afd531f6642fcaa49c48 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Fri, 17 Apr 2026 13:01:51 +0200 Subject: [PATCH] Add event listeners for attachment menu in App.jsx --- src/App.jsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/App.jsx b/src/App.jsx index 17b61bd..4445870 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -2149,6 +2149,23 @@ async function regenerateFromIndex(index, overrideUserText = null) { setIsChatModelPickerOpen(false) }, [activeSessionId, activeSidebarMode]) + useEffect(() => { + if (!isAttachmentMenuOpen) return + + const onPointerDown = (event) => { + if (!attachmentMenuRef.current?.contains(event.target)) { + setIsAttachmentMenuOpen(false) + } + } + + document.addEventListener('mousedown', onPointerDown) + return () => document.removeEventListener('mousedown', onPointerDown) + }, [isAttachmentMenuOpen]) + + useEffect(() => { + setIsAttachmentMenuOpen(false) + }, [activeSessionId, activeSidebarMode, canAttachImages]) + // Persist the scrollTop of the session we are LEAVING (on chat change or when leaving the chat view) useEffect(() => { const leavingSessionId = activeSessionId;