From e3f3a918c8506db1021ec3d5380b3b1f27824ee1 Mon Sep 17 00:00:00 2001 From: samhere06 Date: Mon, 11 May 2026 17:02:57 +0530 Subject: [PATCH 1/2] Fix: attachemnt changes for EA-D5178,EA-D4802,EA-D4791 --- .../SimpleTableManual/SimpleTableManual.tsx | 2 +- .../widget/Attachment/Attachment.tsx | 44 ++++++++++++------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/packages/react-sdk-components/src/components/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx b/packages/react-sdk-components/src/components/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx index 1c0d72cb..0ecef92d 100644 --- a/packages/react-sdk-components/src/components/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +++ b/packages/react-sdk-components/src/components/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx @@ -251,7 +251,7 @@ export default function SimpleTableManual(props: PropsWithChildren(null); const rawValue = pConn.getComponentConfig().value; const isAttachmentAnnotationPresent = typeof rawValue === 'object' ? false : rawValue?.includes('@ATTACHMENT'); @@ -86,7 +86,8 @@ export default function Attachment(props: AttachmentProps) { const deleteFile = useCallback( file => { - setAnchorEl(null); + setMenuAnchorEl(null); + setMenuOpenIndex(null); // reset the file input so that it will allow re-uploading the same file after deletion if (fileInputRef.current) { @@ -98,9 +99,11 @@ export default function Attachment(props: AttachmentProps) { // If file to be deleted is the one added in previous stage i.e. for which a file instance is created in server // no need to filter currentAttachmentList as we will get another entry of file in redux with delete & label - if (hasUploadedFiles && isFileUploadedToServer(file)) { - const updatedAttachments = files.map(f => { - if (f.responseProps && f.responseProps.pzInsKey === file.responseProps.pzInsKey) { + if (hasUploadedFiles && isFileUploadedToServer(file) && file.responseProps?.ID) { + // Use currentAttachmentList (fresh from store) instead of files (stale closure) + // to preserve delete markers set by previous deletions in the same session + const updatedAttachments = currentAttachmentList.map(f => { + if (f.responseProps && f.responseProps.ID === file.responseProps.ID) { return { ...f, delete: true, label: valueRef }; } return f; @@ -109,7 +112,7 @@ export default function Attachment(props: AttachmentProps) { // updating the redux store to help form-handler in passing the data to delete the file from server updateAttachmentState(pConn, getAttachmentKey(valueRef, embeddedProperty), [...updatedAttachments]); setFiles(current => { - const newlyAddedFiles = current.filter(f => !!f.ID); + const newlyAddedFiles = current.filter(f => !!f.ID && f.ID !== file.ID); const filesPostDelete = current.filter(f => isFileUploadedToServer(f) && f.responseProps?.ID !== file.responseProps?.ID); attachmentsList = [...filesPostDelete, ...newlyAddedFiles]; return attachmentsList; @@ -257,7 +260,7 @@ export default function Attachment(props: AttachmentProps) { .filter(e => { const isFileUploaded = e.props && e.props.progress === 100; const fileHasError = e.props && e.props.error; - const isFileUploadedinLastStep = e.responseProps && e.responseProps.pzInsKey; + const isFileUploadedinLastStep = e.responseProps && (e.responseProps.pzInsKey || e.responseProps.ID); return !isFileUploaded && !fileHasError && !isFileUploadedinLastStep; }) .map(f => @@ -361,12 +364,14 @@ export default function Attachment(props: AttachmentProps) { }; }, []); - const handleClick = event => { - setAnchorEl(event.currentTarget); + const handleClick = (event, index) => { + setMenuAnchorEl(event.currentTarget); + setMenuOpenIndex(index); }; const handleClose = () => { - setAnchorEl(null); + setMenuAnchorEl(null); + setMenuOpenIndex(null); }; const content = ( @@ -429,20 +434,27 @@ export default function Attachment(props: AttachmentProps) {
handleClick(event, index)} size='large' > - + { - setAnchorEl(null); + handleClose(); onFileDownload(item.responseProps ? item.responseProps : {}); }} > From 1b443b91220cf2139123412d4af559356120f90f Mon Sep 17 00:00:00 2001 From: samhere06 Date: Mon, 18 May 2026 13:16:59 +0530 Subject: [PATCH 2/2] Updated attachment to use ID instead of pzInskey --- .../src/components/widget/Attachment/Attachment.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/react-sdk-components/src/components/widget/Attachment/Attachment.tsx b/packages/react-sdk-components/src/components/widget/Attachment/Attachment.tsx index 57719208..9b628684 100644 --- a/packages/react-sdk-components/src/components/widget/Attachment/Attachment.tsx +++ b/packages/react-sdk-components/src/components/widget/Attachment/Attachment.tsx @@ -99,7 +99,7 @@ export default function Attachment(props: AttachmentProps) { // If file to be deleted is the one added in previous stage i.e. for which a file instance is created in server // no need to filter currentAttachmentList as we will get another entry of file in redux with delete & label - if (hasUploadedFiles && isFileUploadedToServer(file) && file.responseProps?.ID) { + if (hasUploadedFiles && isFileUploadedToServer(file)) { // Use currentAttachmentList (fresh from store) instead of files (stale closure) // to preserve delete markers set by previous deletions in the same session const updatedAttachments = currentAttachmentList.map(f => { @@ -112,7 +112,7 @@ export default function Attachment(props: AttachmentProps) { // updating the redux store to help form-handler in passing the data to delete the file from server updateAttachmentState(pConn, getAttachmentKey(valueRef, embeddedProperty), [...updatedAttachments]); setFiles(current => { - const newlyAddedFiles = current.filter(f => !!f.ID && f.ID !== file.ID); + const newlyAddedFiles = current.filter(f => !!f.ID); const filesPostDelete = current.filter(f => isFileUploadedToServer(f) && f.responseProps?.ID !== file.responseProps?.ID); attachmentsList = [...filesPostDelete, ...newlyAddedFiles]; return attachmentsList; @@ -291,7 +291,7 @@ export default function Attachment(props: AttachmentProps) { f.label = valueRef; f.category = categoryName; f.responseProps = { - pzInsKey: 'temp', + ID: 'temp', pyAttachName: f.props.name }; } @@ -443,9 +443,10 @@ export default function Attachment(props: AttachmentProps) {