@@ -159,11 +159,12 @@ export class AttachmentComponent implements OnInit, OnDestroy {
159159 const rawValue = this . pConn$ . getComponentConfig ( ) . value ;
160160 const isAttachmentAnnotationPresent = typeof rawValue === 'object' ? false : rawValue ?. includes ( '@ATTACHMENT' ) ;
161161 const { attachments, isOldAttachment } = isAttachmentAnnotationPresent ? value : PCore . getAttachmentUtils ( ) . prepareAttachmentData ( value ) ;
162+ const isAttachmentsChanged = ! PCore . isDeepEqual ( this . attachments , attachments ) ; // JSON.stringify(this.attachments) !== JSON.stringify(attachments);
162163 this . isOldAttachment = isOldAttachment ;
163164 this . attachments = attachments ;
164165
165166 // update the attachments shown in the UI
166- if ( this . attachments . length ) {
167+ if ( isAttachmentsChanged ) {
167168 this . updateAttachments ( ) ;
168169 }
169170 }
@@ -339,12 +340,6 @@ export class AttachmentComponent implements OnInit, OnDestroy {
339340
340341 populateErrorAndUpdateRedux ( file ) {
341342 const fieldName = ( this . pConn$ . getStateProps ( ) as any ) . value ;
342- insertAttachments ( [ file ] , this . pConn$ , this . multiAttachmentsInInlineEdit , {
343- allowMultiple : this . allowMultiple$ ,
344- isOldAttachment : this . isOldAttachment ,
345- isMultiAttachmentInInlineEditTable : this . isMultiAttachmentInInlineEditTable ,
346- attachmentCount : this . attachmentCount
347- } as any ) ;
348343 // set errors to property to block submit even on errors in file upload
349344 PCore . getMessageManager ( ) . addMessages ( {
350345 messages : [
@@ -357,6 +352,12 @@ export class AttachmentComponent implements OnInit, OnDestroy {
357352 pageReference : this . pConn$ . getPageReference ( ) ,
358353 context : this . contextName
359354 } ) ;
355+ insertAttachments ( [ file ] , this . pConn$ , this . multiAttachmentsInInlineEdit , {
356+ allowMultiple : this . allowMultiple$ ,
357+ isOldAttachment : this . isOldAttachment ,
358+ isMultiAttachmentInInlineEditTable : this . isMultiAttachmentInInlineEditTable ,
359+ attachmentCount : this . attachmentCount
360+ } as any ) ;
360361 }
361362
362363 errorHandler ( isFetchCanceled , file ) {
@@ -421,6 +422,7 @@ export class AttachmentComponent implements OnInit, OnDestroy {
421422 fileResponses [ index ] . value . thumbnail = localFile . props . thumbnail ;
422423 localFile . inProgress = false ;
423424 localFile . ID = fileResponses [ index ] . value . ID ;
425+ localFile . props . id = fileResponses [ index ] . value . ID ;
424426 localFile . props . meta = this . localizationService . getLocalizedText ( 'Uploaded successfully' ) ;
425427 localFile . props . progress = 100 ;
426428 localFile . handle = fileResponses [ index ] . value . ID ;
0 commit comments