This commit is contained in:
2025-10-27 21:06:29 +01:00
parent db07e0debb
commit 7ed06ccdcf
2 changed files with 43 additions and 8 deletions
+35 -6
View File
@@ -235,6 +235,7 @@ const DocumentsTable = ({
[activeCorrespondentIds], [activeCorrespondentIds],
); );
const scrollRef = useRef(null); const scrollRef = useRef(null);
const suppressDocumentClickRef = useRef(false);
const [, forceVisibilityTick] = useState(0); const [, forceVisibilityTick] = useState(0);
const lastScrollNodeRef = useRef(null); const lastScrollNodeRef = useRef(null);
const assignScrollRef = useCallback((node) => { const assignScrollRef = useCallback((node) => {
@@ -373,6 +374,34 @@ const DocumentsTable = ({
[isTagDragEvent, onDocumentTagDrop], [isTagDragEvent, onDocumentTagDrop],
); );
const handleDocumentClick = useCallback(
(documentId, event) => {
if (suppressDocumentClickRef.current) {
return;
}
onDocumentRowClick?.(documentId, event);
},
[onDocumentRowClick],
);
const handleDocumentDragStartLocal = useCallback(
(event, doc) => {
suppressDocumentClickRef.current = true;
onDocumentDragStart?.(event, doc);
},
[onDocumentDragStart],
);
const handleDocumentDragEndLocal = useCallback(
(event) => {
onDocumentDragEnd?.(event);
requestAnimationFrame(() => {
suppressDocumentClickRef.current = false;
});
},
[onDocumentDragEnd],
);
const renderCorrespondentLinks = useCallback( const renderCorrespondentLinks = useCallback(
(correspondents) => (correspondents) =>
correspondents.map((correspondent, index) => { correspondents.map((correspondent, index) => {
@@ -594,11 +623,11 @@ const DocumentsTable = ({
role="listitem" role="listitem"
id={`document-card-${doc.id}`} id={`document-card-${doc.id}`}
data-doc-id={doc.id} data-doc-id={doc.id}
onClick={(event) => onDocumentRowClick(doc.id, event)} onClick={(event) => handleDocumentClick(doc.id, event)}
onDoubleClick={() => onDocumentOpen(doc.id)} onDoubleClick={() => onDocumentOpen(doc.id)}
draggable draggable
onDragStart={(event) => onDocumentDragStart(event, doc)} onDragStart={(event) => handleDocumentDragStartLocal(event, doc)}
onDragEnd={onDocumentDragEnd} onDragEnd={handleDocumentDragEndLocal}
onDragOver={(event) => handleDocumentTagDragOver(event)} onDragOver={(event) => handleDocumentTagDragOver(event)}
onDragOverCapture={(event) => handleDocumentTagDragOver(event)} onDragOverCapture={(event) => handleDocumentTagDragOver(event)}
onDragLeave={handleDocumentTagDragLeave} onDragLeave={handleDocumentTagDragLeave}
@@ -818,11 +847,11 @@ const DocumentsTable = ({
className={rowClasses.join(' ')} className={rowClasses.join(' ')}
id={`document-row-${doc.id}`} id={`document-row-${doc.id}`}
data-doc-id={doc.id} data-doc-id={doc.id}
onClick={(event) => onDocumentRowClick(doc.id, event)} onClick={(event) => handleDocumentClick(doc.id, event)}
onDoubleClick={() => onDocumentOpen(doc.id)} onDoubleClick={() => onDocumentOpen(doc.id)}
draggable draggable
onDragStart={(event) => onDocumentDragStart(event, doc)} onDragStart={(event) => handleDocumentDragStartLocal(event, doc)}
onDragEnd={onDocumentDragEnd} onDragEnd={handleDocumentDragEndLocal}
onDragOver={handleDocumentTagDragOver} onDragOver={handleDocumentTagDragOver}
onDragLeave={handleDocumentTagDragLeave} onDragLeave={handleDocumentTagDragLeave}
onDrop={(event) => handleDocumentTagDrop(event, doc.id)} onDrop={(event) => handleDocumentTagDrop(event, doc.id)}
+8 -2
View File
@@ -2836,11 +2836,16 @@ const AppLayout = () => {
return; return;
} }
const isGridView = documentsViewMode === 'grid';
const isAlreadySelected = selectedDocumentIds.includes(documentId); const isAlreadySelected = selectedDocumentIds.includes(documentId);
const selection = isAlreadySelected ? [...selectedDocumentIds] : [documentId]; const selection = isAlreadySelected
? [...selectedDocumentIds]
: isGridView
? [...selectedDocumentIds, documentId]
: [documentId];
const folderSelection = selectedFolderIds.length ? [...selectedFolderIds] : []; const folderSelection = selectedFolderIds.length ? [...selectedFolderIds] : [];
if (!isAlreadySelected) { if (!isAlreadySelected && !isGridView) {
applySelection([documentKey], { applySelection([documentKey], {
anchor: documentKey, anchor: documentKey,
interactedKeys: [documentKey], interactedKeys: [documentKey],
@@ -2890,6 +2895,7 @@ const AppLayout = () => {
documentLookup, documentLookup,
createDragPreview, createDragPreview,
setDraggedFolderId, setDraggedFolderId,
documentsViewMode,
], ],
); );