Add click outside functionality to chat model picker and close on session change
This commit is contained in:
17
src/App.jsx
17
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;
|
||||
|
||||
Reference in New Issue
Block a user