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 = [],
selectedDocumentIds = [],
onClearSelection = null,
detailPanelOpen = false,
onCloseDetailPanel = null,
helpOpen = false,
onHelpClose = null,
tenantId = null,
@@ -1849,6 +1851,8 @@ const recalcVisibleDocIds = useCallback(() => {
markLayoutDirty,
selectedDocumentIds,
onClearSelection,
detailPanelOpen,
onCloseDetailPanel,
}),
[
activeTagSet,
@@ -1897,6 +1901,8 @@ const recalcVisibleDocIds = useCallback(() => {
onClearSelection,
onDocumentStackSelect,
markLayoutDirty,
detailPanelOpen,
onCloseDetailPanel,
],
);
@@ -1945,6 +1951,8 @@ const DesktopWorkspaceView = () => {
onDocumentStackSelect,
selectedDocumentIds,
onClearSelection,
detailPanelOpen,
onCloseDetailPanel,
documentLookup,
} = useDesktopContext();
@@ -2151,11 +2159,8 @@ const DesktopWorkspaceView = () => {
}
const key = event.key;
if (!(key === ' ' || key === 'Space' || key === 'Spacebar')) {
return;
}
if (!selectedDocumentIds || selectedDocumentIds.length === 0) {
const spacePressed = key === ' ' || key === 'Space' || key === 'Spacebar';
if (!spacePressed) {
return;
}
@@ -2173,13 +2178,27 @@ const DesktopWorkspaceView = () => {
}
}
event.preventDefault();
onClearSelection();
const hasSelection = Array.isArray(selectedDocumentIds) && selectedDocumentIds.length > 0;
if (hasSelection) {
event.preventDefault();
onClearSelection();
return;
}
if (detailPanelOpen && typeof onCloseDetailPanel === 'function') {
event.preventDefault();
onCloseDetailPanel();
}
};
window.addEventListener('keydown', handleKeyDown, true);
return () => window.removeEventListener('keydown', handleKeyDown, true);
}, [onClearSelection, selectedDocumentIds]);
}, [
onClearSelection,
selectedDocumentIds,
detailPanelOpen,
onCloseDetailPanel,
]);
return (
<>
@@ -2284,32 +2303,39 @@ const DesktopWorkspaceView = () => {
(event.metaKey || event.ctrlKey) && !event.shiftKey && !event.altKey;
let stackDocIds = null;
if (
metaOrCtrlOnly
&& selectedDocumentIds.length === 0
&& typeof onDocumentStackSelect === 'function'
) {
let appliedStackSelection = false;
if (metaOrCtrlOnly) {
const hits = resolveStackDocIds(event, doc.id);
if (Array.isArray(hits) && hits.length > 0) {
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;
if (
!stackHandled
&& typeof onDocumentPointerSelect === 'function'
&& (!alreadySelected
|| event.metaKey
|| event.ctrlKey
const shouldInvokePointerSelect =
typeof onDocumentPointerSelect === 'function'
&& (
!metaOrCtrlOnly
|| !alreadySelected
|| event.shiftKey
|| event.altKey)
) {
|| event.altKey
|| !stackDocIds
|| stackDocIds.length <= 1
);
if (shouldInvokePointerSelect) {
onDocumentPointerSelect(doc.id, event);
}
handlePointerDown(event, doc.id, { stackDocIds });
handlePointerDown(event, doc.id, {
stackDocIds,
stackSelectionApplied: appliedStackSelection,
});
}}
onPointerMove={handlePointerMove}
onPointerUp={handlePointerUp}