Focus on right click file

This commit is contained in:
Dustin Brett
2021-08-07 22:05:15 -07:00
parent 554d8b5bc4
commit b64bbefef2
2 changed files with 14 additions and 3 deletions

View File

@@ -70,7 +70,14 @@ const FileEntry = ({
<Button
ref={buttonRef}
{...useDoubleClick(() => openFile(pid), singleClick)}
{...useFileContextMenu(url, pid, path, setRenaming, fileActions)}
{...useFileContextMenu(
url,
pid,
path,
setRenaming,
fileActions,
focusEntry
)}
>
<figure>
<Icon src={icon} alt={name} {...FileEntryIconSize[view]} />

View File

@@ -18,7 +18,8 @@ const useFileContextMenu = (
pid: string,
path: string,
setRenaming: React.Dispatch<React.SetStateAction<string>>,
{ deleteFile, downloadFile }: FileActions
{ deleteFile, downloadFile }: FileActions,
focusEntry: (entry: string) => void
): { onContextMenuCapture: React.MouseEventHandler<HTMLElement> } => {
const { open } = useProcesses();
const { setWallpaper } = useSession();
@@ -104,7 +105,10 @@ const useFileContextMenu = (
}
return {
onContextMenuCapture: contextMenu?.(menuItems),
onContextMenuCapture: (event) => {
focusEntry(basename(path));
contextMenu?.(menuItems)(event);
},
};
};