File tree Expand file tree Collapse file tree 1 file changed +6
-10
lines changed
openaev-front/src/components/fields Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Original file line number Diff line number Diff 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 ] ) ;
You can’t perform that action at this time.
0 commit comments