From c6c2edc2611a35eaaada2e836ee0b04e39ad6fbb Mon Sep 17 00:00:00 2001 From: Dustin Brett Date: Sun, 12 Jan 2025 23:02:44 -0800 Subject: [PATCH] Only focus window on initial load --- components/system/Files/FileManager/index.tsx | 4 +++- hooks/useSnapshots.ts | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/components/system/Files/FileManager/index.tsx b/components/system/Files/FileManager/index.tsx index 11cdc4bd..2c941638 100644 --- a/components/system/Files/FileManager/index.tsx +++ b/components/system/Files/FileManager/index.tsx @@ -134,6 +134,7 @@ const FileManager: FC = ({ ); const [permission, setPermission] = useState("prompt"); const requestingPermissions = useRef(false); + const focusedOnLoad = useRef(false); const onKeyDown = useMemo( () => (renaming === "" ? keyShortcuts() : undefined), [keyShortcuts, renaming] @@ -207,8 +208,9 @@ const FileManager: FC = ({ }, [currentUrl, folderActions, url]); useEffect(() => { - if (!loading && !isDesktop && !isStartMenu) { + if (!focusedOnLoad.current && !loading && !isDesktop && !isStartMenu) { fileManagerRef.current?.focus(PREVENT_SCROLL); + focusedOnLoad.current = true; } }, [isDesktop, isStartMenu, loading]); diff --git a/hooks/useSnapshots.ts b/hooks/useSnapshots.ts index c4f44205..bb3cca55 100644 --- a/hooks/useSnapshots.ts +++ b/hooks/useSnapshots.ts @@ -49,7 +49,6 @@ export const useSnapshots = (): Snapshot => { } } - // TODO: Update icon but don't focus updateFolder(dirname(savePath)); updateFolder(savePath, saveName); } catch {