Skip to content

Commit

Permalink
Properly open selected folder on middle click
Browse files Browse the repository at this point in the history
  • Loading branch information
leomoty committed Jun 28, 2024
1 parent 4880646 commit 426bdc9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/files-card-body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,20 @@ export const FilesCardBody = ({
}
};

const handleAuxClick = (ev: MouseEvent) => {
// capture middle click
if (ev.button === 1) {
ev.preventDefault();
const name = getFilenameForEvent(ev);
const file = sortedFiles?.find(file => file.name === name);

if (file && file.to === "dir"){
const query = [...path, file.name].join("/");
open(`#/?path=${query}`)
}
}
}

const handleContextMenu = (event: MouseEvent) => {
const name = getFilenameForEvent(event);
if (name !== null && selected.length > 1) {
Expand Down Expand Up @@ -273,6 +287,7 @@ export const FilesCardBody = ({
folderViewElem.addEventListener("click", handleClick);
folderViewElem.addEventListener("dblclick", handleDoubleClick);
folderViewElem.addEventListener("contextmenu", handleContextMenu);
folderViewElem.addEventListener("auxclick", handleAuxClick);
}

if (!isMounted.current && !dialogs.isActive()) {
Expand All @@ -288,6 +303,7 @@ export const FilesCardBody = ({
folderViewElem.removeEventListener("click", handleClick);
folderViewElem.removeEventListener("dblclick", handleDoubleClick);
folderViewElem.removeEventListener("contextmenu", handleContextMenu);
folderViewElem.removeEventListener("auxclick", handleAuxClick);
}
};
}, [
Expand Down

0 comments on commit 426bdc9

Please sign in to comment.