Skip to content

Commit 7fe2fdc

Browse files
committed
[frontend] document list
1 parent fa9172c commit 7fe2fdc

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

openaev-front/src/components/fields/FileTransferDialog.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,16 @@ const FileTransferDialog: FunctionComponent<Props> = ({
6969
const { documents }: { documents: [RawDocument] } = useHelper((helper: DocumentHelper & UserHelper) => ({ documents: helper.getDocuments() }));
7070

7171
useEffect(() => {
72-
// If initial data hasn't arrived yet or selectedDocuments already matches it, do nothing
72+
// If initial data hasn't arrived yet, do nothing
7373
if (initialDocumentIds.length === 0) return;
74-
const selectedIds = selectedDocuments.map(d => d.document_id);
7574

76-
const sameArray
77-
= selectedIds.length === initialDocumentIds.length
78-
&& initialDocumentIds.every(id => selectedIds.includes(id));
75+
// If we already have selected documents, don't override user changes
76+
if (selectedDocuments.length > 0) return;
7977

80-
if (sameArray) return;
81-
82-
// Otherwise, update selectedDocuments
78+
// Initialize selectedDocuments from initialDocumentIds (only once)
8379
setSelectedDocuments(
84-
documents.filter(doc =>
85-
doc.document_id && initialDocumentIds.includes(doc.document_id),
80+
documents.filter(
81+
doc => doc.document_id && initialDocumentIds.includes(doc.document_id),
8682
),
8783
);
8884
}, [initialDocumentIds]);

0 commit comments

Comments
 (0)