This commit is contained in:
2025-11-07 23:48:25 +01:00
parent 8dd6be2a5d
commit 4bc7357e41
7 changed files with 77 additions and 38 deletions
+21 -3
View File
@@ -703,7 +703,6 @@ const DesktopWorkspace = ({
onDocumentOpen,
onDocumentStackSelect,
onEntryPointer,
onInspectDocument,
onPromoteSelection,
openOverlayForDoc,
overlayDisplay,
@@ -717,6 +716,7 @@ const DesktopWorkspace = ({
setDraggingId,
selectedDocumentIds,
detailPanelOpen,
onInspectDocument,
markLayoutDirty,
tagDropTargetId,
visibleDocIds,
@@ -804,7 +804,7 @@ const DesktopWorkspaceView = ({
markLayoutDirty,
});
const { getCardPointerHandlers, handleShellKeyDown } = useDeskPointer({
const { getCardPointerHandlers, handleShellKeyDown, focusShell } = useDeskPointer({
containerRef,
items,
layoutRef,
@@ -819,11 +819,27 @@ const DesktopWorkspaceView = ({
onPromoteSelection,
onDocumentOpen,
selectedDocumentIds,
onClearSelection,
detailPanelOpen,
onCloseDetailPanel,
openOverlayForDoc,
});
useEffect(() => {
focusShell();
}, [focusShell]);
useEffect(() => {
if (selectedDocumentIds.length) {
focusShell();
}
}, [focusShell, selectedDocumentIds.length]);
useEffect(() => {
if (!detailPanelOpen) {
focusShell();
}
}, [detailPanelOpen, focusShell]);
const allSizesReady = items.every((doc) => ensureDocumentSize(doc));
@@ -834,6 +850,7 @@ const DesktopWorkspaceView = ({
if (event.target === event.currentTarget && typeof onClearSelection === 'function') {
onClearSelection();
}
focusShell();
}}
>
<div
@@ -848,6 +865,7 @@ const DesktopWorkspaceView = ({
if (event.target === event.currentTarget && typeof onClearSelection === 'function') {
onClearSelection();
}
focusShell();
}}
>
{!allSizesReady ? (
+1 -1
View File
@@ -40,7 +40,7 @@ export const createPointerIntent = ({
clickAction = CLICK_ACTIONS.addStack;
dragAction = DRAG_ACTIONS.dragSelectStack;
} else if (alreadySelected) {
clickAction = CLICK_ACTIONS.openDetail;
clickAction = CLICK_ACTIONS.selectSingle;
dragAction = selectionCount > 1 ? DRAG_ACTIONS.dragSelection : DRAG_ACTIONS.dragSelectSingle;
} else {
clickAction = CLICK_ACTIONS.selectSingle;
+17 -4
View File
@@ -37,9 +37,9 @@ export const useDeskPointer = ({
onPromoteSelection,
onDocumentOpen,
selectedDocumentIds,
onClearSelection,
detailPanelOpen,
onCloseDetailPanel,
openOverlayForDoc = null,
}) => {
const pointerIntentRef = useRef(null);
const pointerStartRef = useRef({ x: 0, y: 0 });
@@ -401,9 +401,16 @@ export const useDeskPointer = ({
}
}
if (Array.isArray(selectedDocumentIds) && selectedDocumentIds.length > 0) {
if (
typeof openOverlayForDoc === 'function'
&& Array.isArray(selectedDocumentIds)
&& selectedDocumentIds.length > 0
) {
event.preventDefault();
onClearSelection?.();
const targetId = selectedDocumentIds[selectedDocumentIds.length - 1];
if (targetId) {
openOverlayForDoc(targetId);
}
return;
}
@@ -412,12 +419,18 @@ export const useDeskPointer = ({
safeInvoke(onCloseDetailPanel);
}
},
[detailPanelOpen, onClearSelection, onCloseDetailPanel, selectedDocumentIds],
[detailPanelOpen, onCloseDetailPanel, openOverlayForDoc, selectedDocumentIds],
);
return {
getCardPointerHandlers,
handleShellKeyDown,
focusShell: () => {
const shell = containerRef.current;
if (shell && typeof shell.focus === 'function') {
shell.focus({ preventScroll: true });
}
},
};
};
+6 -13
View File
@@ -54,25 +54,18 @@ const useDocumentDrag = (options = {}) => {
const tapHandler = usePointerTap({
delay: 220,
onSingle: ({ data, event }) => {
if (!data || !data.docId) {
return;
}
if (event && (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)) {
return;
}
if (typeof onInspectDocument === 'function') {
onInspectDocument(data.docId);
}
},
onSingle: () => {},
onDouble: ({ data, event }) => {
if (!data || !data.docId) {
return;
}
if (event && (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)) {
if (event?.altKey) {
openOverlayForDoc(data.docId, data.originInfo);
return;
}
openOverlayForDoc(data.docId, data.originInfo);
if (typeof onInspectDocument === 'function') {
onInspectDocument(data.docId, event);
}
},
});
const dragStateRef = useRef(null);