This commit is contained in:
2025-11-02 15:44:09 +01:00
parent 866a31b89d
commit f8ab674b84
4 changed files with 99 additions and 31 deletions
+51 -25
View File
@@ -581,6 +581,8 @@ const DesktopWorkspace = ({
activeTagIds = [], activeTagIds = [],
selectedDocumentIds = [], selectedDocumentIds = [],
onClearSelection = null, onClearSelection = null,
detailPanelOpen = false,
onCloseDetailPanel = null,
helpOpen = false, helpOpen = false,
onHelpClose = null, onHelpClose = null,
tenantId = null, tenantId = null,
@@ -1849,6 +1851,8 @@ const recalcVisibleDocIds = useCallback(() => {
markLayoutDirty, markLayoutDirty,
selectedDocumentIds, selectedDocumentIds,
onClearSelection, onClearSelection,
detailPanelOpen,
onCloseDetailPanel,
}), }),
[ [
activeTagSet, activeTagSet,
@@ -1897,6 +1901,8 @@ const recalcVisibleDocIds = useCallback(() => {
onClearSelection, onClearSelection,
onDocumentStackSelect, onDocumentStackSelect,
markLayoutDirty, markLayoutDirty,
detailPanelOpen,
onCloseDetailPanel,
], ],
); );
@@ -1945,6 +1951,8 @@ const DesktopWorkspaceView = () => {
onDocumentStackSelect, onDocumentStackSelect,
selectedDocumentIds, selectedDocumentIds,
onClearSelection, onClearSelection,
detailPanelOpen,
onCloseDetailPanel,
documentLookup, documentLookup,
} = useDesktopContext(); } = useDesktopContext();
@@ -2151,11 +2159,8 @@ const DesktopWorkspaceView = () => {
} }
const key = event.key; const key = event.key;
if (!(key === ' ' || key === 'Space' || key === 'Spacebar')) { const spacePressed = key === ' ' || key === 'Space' || key === 'Spacebar';
return; if (!spacePressed) {
}
if (!selectedDocumentIds || selectedDocumentIds.length === 0) {
return; return;
} }
@@ -2173,13 +2178,27 @@ const DesktopWorkspaceView = () => {
} }
} }
event.preventDefault(); const hasSelection = Array.isArray(selectedDocumentIds) && selectedDocumentIds.length > 0;
onClearSelection(); if (hasSelection) {
event.preventDefault();
onClearSelection();
return;
}
if (detailPanelOpen && typeof onCloseDetailPanel === 'function') {
event.preventDefault();
onCloseDetailPanel();
}
}; };
window.addEventListener('keydown', handleKeyDown, true); window.addEventListener('keydown', handleKeyDown, true);
return () => window.removeEventListener('keydown', handleKeyDown, true); return () => window.removeEventListener('keydown', handleKeyDown, true);
}, [onClearSelection, selectedDocumentIds]); }, [
onClearSelection,
selectedDocumentIds,
detailPanelOpen,
onCloseDetailPanel,
]);
return ( return (
<> <>
@@ -2284,32 +2303,39 @@ const DesktopWorkspaceView = () => {
(event.metaKey || event.ctrlKey) && !event.shiftKey && !event.altKey; (event.metaKey || event.ctrlKey) && !event.shiftKey && !event.altKey;
let stackDocIds = null; let stackDocIds = null;
if ( let appliedStackSelection = false;
metaOrCtrlOnly
&& selectedDocumentIds.length === 0 if (metaOrCtrlOnly) {
&& typeof onDocumentStackSelect === 'function'
) {
const hits = resolveStackDocIds(event, doc.id); const hits = resolveStackDocIds(event, doc.id);
if (Array.isArray(hits) && hits.length > 0) { if (Array.isArray(hits) && hits.length > 0) {
stackDocIds = hits; stackDocIds = hits;
onDocumentStackSelect(hits, event); const hasStack = hits.length > 1;
if (hasStack && alreadySelected && typeof onDocumentStackSelect === 'function') {
onDocumentStackSelect(hits, event);
appliedStackSelection = true;
}
} }
} }
const stackHandled = Array.isArray(stackDocIds) && stackDocIds.length > 0; const shouldInvokePointerSelect =
typeof onDocumentPointerSelect === 'function'
if ( && (
!stackHandled !metaOrCtrlOnly
&& typeof onDocumentPointerSelect === 'function' || !alreadySelected
&& (!alreadySelected
|| event.metaKey
|| event.ctrlKey
|| event.shiftKey || event.shiftKey
|| event.altKey) || event.altKey
) { || !stackDocIds
|| stackDocIds.length <= 1
);
if (shouldInvokePointerSelect) {
onDocumentPointerSelect(doc.id, event); onDocumentPointerSelect(doc.id, event);
} }
handlePointerDown(event, doc.id, { stackDocIds });
handlePointerDown(event, doc.id, {
stackDocIds,
stackSelectionApplied: appliedStackSelection,
});
}} }}
onPointerMove={handlePointerMove} onPointerMove={handlePointerMove}
onPointerUp={handlePointerUp} onPointerUp={handlePointerUp}
+4
View File
@@ -4885,6 +4885,8 @@ const AppLayout = () => {
tenantId: currentTenantId, tenantId: currentTenantId,
selectedDocumentIds, selectedDocumentIds,
onClearSelection: clearDocumentSelection, onClearSelection: clearDocumentSelection,
detailPanelOpen,
onCloseDetailPanel: handleDetailPanelClose,
resolveThumbnailUrl: resolveThumbnailUrlForDoc, resolveThumbnailUrl: resolveThumbnailUrlForDoc,
onAssignTagToDocument: handleDocumentTagAttach, onAssignTagToDocument: handleDocumentTagAttach,
onRemoveTagFromDocument: handleTagRemove, onRemoveTagFromDocument: handleTagRemove,
@@ -4911,6 +4913,8 @@ const AppLayout = () => {
deskHelpOpen, deskHelpOpen,
selectedDocumentIds, selectedDocumentIds,
clearDocumentSelection, clearDocumentSelection,
detailPanelOpen,
handleDetailPanelClose,
resolveThumbnailUrlForDoc, resolveThumbnailUrlForDoc,
handleDocumentTagAttach, handleDocumentTagAttach,
handleTagRemove, handleTagRemove,
+21 -3
View File
@@ -32,6 +32,7 @@ const useDocumentDrag = () => {
containerRef, containerRef,
onDocumentOpen, onDocumentOpen,
onInspectDocument, onInspectDocument,
onDocumentStackSelect,
selectedDocumentIds, selectedDocumentIds,
markLayoutDirty, markLayoutDirty,
} = useDesktopContext(); } = useDesktopContext();
@@ -286,6 +287,7 @@ const useDocumentDrag = () => {
.map((value) => (value != null ? String(value) : null)) .map((value) => (value != null ? String(value) : null))
.filter(Boolean) .filter(Boolean)
: null; : null;
const stackSelectionAppliedInitial = Boolean(options?.stackSelectionApplied);
let selectionIds = Array.isArray(selectedDocumentIds) let selectionIds = Array.isArray(selectedDocumentIds)
? selectedDocumentIds.map((id) => String(id)) ? selectedDocumentIds.map((id) => String(id))
@@ -416,6 +418,8 @@ const useDocumentDrag = () => {
? performance.now() ? performance.now()
: Date.now(); : Date.now();
const hasStackSource = Array.isArray(stackDocIdsOption) && stackDocIdsOption.length > 1;
dragStateRef.current = { dragStateRef.current = {
docId, docId,
docKey, docKey,
@@ -444,9 +448,11 @@ const useDocumentDrag = () => {
containerRectTop: containerTop, containerRectTop: containerTop,
isGroup: isGroupDrag, isGroup: isGroupDrag,
groupDocIds, groupDocIds,
groupItems, groupItems,
groupElevated: !isGroupDrag, groupElevated: !isGroupDrag,
}; stackDocIds: hasStackSource ? stackDocIdsOption : null,
stackSelectionApplied: stackSelectionAppliedInitial || !hasStackSource,
};
setDraggingId(docId); setDraggingId(docId);
@@ -524,6 +530,17 @@ const useDocumentDrag = () => {
return; return;
} }
state.moved = true; state.moved = true;
if (
state.isGroup
&& !state.stackSelectionApplied
&& Array.isArray(state.stackDocIds)
&& state.stackDocIds.length > 1
) {
if (typeof onDocumentStackSelect === 'function') {
onDocumentStackSelect(state.stackDocIds);
}
state.stackSelectionApplied = true;
}
if (!state.groupElevated) { if (!state.groupElevated) {
const layout = layoutRef.current; const layout = layoutRef.current;
const sortedGroup = state.groupDocIds const sortedGroup = state.groupDocIds
@@ -811,6 +828,7 @@ const useDocumentDrag = () => {
applyTransform, applyTransform,
recalcVisibleDocIds, recalcVisibleDocIds,
debugDrag, debugDrag,
onDocumentStackSelect,
], ],
); );
+23 -3
View File
@@ -173,13 +173,33 @@ const PreviewZoomOverlay = ({
return; return;
} }
if (event.key === 'Escape') { const key = event.key;
if (key === ' ' || key === 'Space' || key === 'Spacebar') {
const target = event.target;
if (target instanceof HTMLElement) {
const tag = target.tagName ? target.tagName.toLowerCase() : '';
if (
target.isContentEditable
|| tag === 'input'
|| tag === 'textarea'
|| tag === 'select'
) {
return;
}
}
event.preventDefault(); event.preventDefault();
onClose(); onClose();
return; return;
} }
if (event.key === 'ArrowLeft') { if (key === 'Escape') {
event.preventDefault();
onClose();
return;
}
if (key === 'ArrowLeft') {
if (activeDisplay?.canGoPrev && activeDisplay?.goPrev) { if (activeDisplay?.canGoPrev && activeDisplay?.goPrev) {
event.preventDefault(); event.preventDefault();
activeDisplay.goPrev(); activeDisplay.goPrev();
@@ -187,7 +207,7 @@ const PreviewZoomOverlay = ({
return; return;
} }
if (event.key === 'ArrowRight') { if (key === 'ArrowRight') {
if (activeDisplay?.canGoNext && activeDisplay?.goNext) { if (activeDisplay?.canGoNext && activeDisplay?.goNext) {
event.preventDefault(); event.preventDefault();
activeDisplay.goNext(); activeDisplay.goNext();