From 98294755ee4ef4c0eca1d5600e2509fcfde057fe Mon Sep 17 00:00:00 2001 From: Dustin Healy <54083382+dustinhealy@users.noreply.github.com> Date: Thu, 18 Dec 2025 10:36:19 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=81=EF=B8=8F=20fix:=20Return=20Focus?= =?UTF-8?q?=20on=20My=20Files=20Modal=20Close=20(#11032)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: focus returns to manage files button on modal close * refactor: remove atoms and re-use components instead * refactor: FilesView to MyFilesModal * chore: import styling * chore: delete file that was meant to be renamed * feat: add trigger ref for settings button as well --- .../Files/{FilesView.tsx => MyFilesModal.tsx} | 12 ++++++++++-- client/src/components/Nav/AccountSettings.tsx | 18 ++++++++++++------ .../components/SidePanel/Files/PanelTable.tsx | 16 +++++++++++----- client/src/store/settings.ts | 1 - 4 files changed, 33 insertions(+), 14 deletions(-) rename client/src/components/Chat/Input/Files/{FilesView.tsx => MyFilesModal.tsx} (78%) diff --git a/client/src/components/Chat/Input/Files/FilesView.tsx b/client/src/components/Chat/Input/Files/MyFilesModal.tsx similarity index 78% rename from client/src/components/Chat/Input/Files/FilesView.tsx rename to client/src/components/Chat/Input/Files/MyFilesModal.tsx index 13a378b93d..098b738b33 100644 --- a/client/src/components/Chat/Input/Files/FilesView.tsx +++ b/client/src/components/Chat/Input/Files/MyFilesModal.tsx @@ -5,7 +5,15 @@ import { useGetFiles } from '~/data-provider'; import { DataTable, columns } from './Table'; import { useLocalize } from '~/hooks'; -export default function Files({ open, onOpenChange }) { +export function MyFilesModal({ + open, + onOpenChange, + triggerRef, +}: { + open: boolean; + onOpenChange: (open: boolean) => void; + triggerRef?: React.RefObject; +}) { const localize = useLocalize(); const { data: files = [] } = useGetFiles({ @@ -18,7 +26,7 @@ export default function Files({ open, onOpenChange }) { }); return ( - + (null); return ( - {showFiles && } + {showFiles && ( + + )} {showSettings && } ); diff --git a/client/src/components/SidePanel/Files/PanelTable.tsx b/client/src/components/SidePanel/Files/PanelTable.tsx index ca2cc2deec..f9e3f48e8d 100644 --- a/client/src/components/SidePanel/Files/PanelTable.tsx +++ b/client/src/components/SidePanel/Files/PanelTable.tsx @@ -1,6 +1,5 @@ -import { useState, useCallback, useMemo } from 'react'; +import { useState, useCallback, useMemo, useRef } from 'react'; import { ArrowUpLeft } from 'lucide-react'; -import { useSetRecoilState } from 'recoil'; import { Button, Input, @@ -33,10 +32,10 @@ import { getEndpointFileConfig, type TFile, } from 'librechat-data-provider'; +import { MyFilesModal } from '~/components/Chat/Input/Files/MyFilesModal'; import { useFileMapContext, useChatContext } from '~/Providers'; import { useLocalize, useUpdateFiles } from '~/hooks'; import { useGetFileConfig } from '~/data-provider'; -import store from '~/store'; interface DataTableProps { columns: ColumnDef[]; @@ -49,7 +48,8 @@ export default function DataTable({ columns, data }: DataTablePro const [columnFilters, setColumnFilters] = useState([]); const [columnVisibility, setColumnVisibility] = useState({}); const [{ pageIndex, pageSize }, setPagination] = useState({ pageIndex: 0, pageSize: 10 }); - const setShowFiles = useSetRecoilState(store.showFiles); + const [showFilesModal, setShowFilesModal] = useState(false); + const manageFilesRef = useRef(null); const pagination = useMemo( () => ({ @@ -301,9 +301,10 @@ export default function DataTable({ columns, data }: DataTablePro
+ ); } diff --git a/client/src/store/settings.ts b/client/src/store/settings.ts index 50c1ce3d54..ece96d119a 100644 --- a/client/src/store/settings.ts +++ b/client/src/store/settings.ts @@ -6,7 +6,6 @@ import type { TOptionSettings } from '~/common'; // Static atoms without localStorage const staticAtoms = { abortScroll: atom({ key: 'abortScroll', default: false }), - showFiles: atom({ key: 'showFiles', default: false }), optionSettings: atom({ key: 'optionSettings', default: {} }), currentSettingsView: atom({ key: 'currentSettingsView',