mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-05-04 21:35:43 -04:00
[ENG-710] Fix explorer view context menu (#933)
* Fix context menu on overview * Fix double click action * fix propagation & switch to onMouseDown
This commit is contained in:
@@ -253,7 +253,7 @@ export default () => {
|
||||
e: React.MouseEvent<HTMLDivElement, MouseEvent>,
|
||||
row: Row<ExplorerItem>
|
||||
) {
|
||||
if (!explorerView.onSelectedChange) return;
|
||||
if (!explorerView.onSelectedChange || e.button !== 0) return;
|
||||
|
||||
const rowIndex = row.index;
|
||||
const itemId = row.original.item.id;
|
||||
@@ -328,7 +328,7 @@ export default () => {
|
||||
}
|
||||
|
||||
explorerView.onSelectedChange?.([...updated]);
|
||||
} else if (e.button === 0) {
|
||||
} else {
|
||||
explorerView.onSelectedChange(explorerView.multiSelect ? [itemId] : itemId);
|
||||
setRanges([[itemId, itemId]]);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
ViewContext,
|
||||
useExplorerViewContext
|
||||
} from '../ViewContext';
|
||||
import { getItemFilePath } from '../util';
|
||||
import { getExplorerItemData, getItemFilePath } from '../util';
|
||||
import GridView from './GridView';
|
||||
import ListView from './ListView';
|
||||
import MediaView from './MediaView';
|
||||
@@ -62,6 +62,12 @@ export const ViewItem = ({ data, children, ...props }: ViewItemProps) => {
|
||||
}
|
||||
|
||||
openFilePath(library.uuid, filePath.id);
|
||||
} else {
|
||||
const { kind } = getExplorerItemData(data);
|
||||
|
||||
if (['Video', 'Image', 'Audio'].includes(kind)) {
|
||||
getExplorerStore().quickViewObject = data;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ export default function Explorer(props: Props) {
|
||||
selectedItemId
|
||||
? props.items?.find((item) => item.item.id === selectedItemId)
|
||||
: undefined,
|
||||
[selectedItemId]
|
||||
[selectedItemId, props.items]
|
||||
);
|
||||
|
||||
useLibrarySubscription(['jobs.newThumbnail'], {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { useMemo, useState } from 'react';
|
||||
import 'react-loading-skeleton/dist/skeleton.css';
|
||||
import { useKey } from 'rooks';
|
||||
import { Category } from '@sd/client';
|
||||
import { z } from '@sd/ui/src/forms';
|
||||
import { getExplorerStore, useExplorerStore, useExplorerTopBarOptions } from '~/hooks';
|
||||
import { useExplorerStore, useExplorerTopBarOptions } from '~/hooks';
|
||||
import ContextMenu from '../Explorer/File/ContextMenu';
|
||||
import { Inspector } from '../Explorer/Inspector';
|
||||
import View from '../Explorer/View';
|
||||
@@ -33,7 +32,7 @@ export const Component = () => {
|
||||
|
||||
const selectedItem = useMemo(
|
||||
() => (selectedItemId ? items?.find((item) => item.item.id === selectedItemId) : undefined),
|
||||
[selectedItemId]
|
||||
[selectedItemId, items]
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -63,7 +62,7 @@ export const Component = () => {
|
||||
onSelectedChange={setSelectedItemId}
|
||||
top={68}
|
||||
className={explorerStore.layoutMode === 'rows' ? 'min-w-0' : undefined}
|
||||
contextMenu={selectedItem && <ContextMenu data={selectedItem} />}
|
||||
contextMenu={<ContextMenu data={selectedItem} />}
|
||||
emptyNotice={null}
|
||||
/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user