Skip to content

Commit 2039ec4

Browse files
tammy-a11ysamhere06
authored andcommitted
fix: Redux to update files properly after removing from UI
1 parent aedc2ea commit 2039ec4

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

packages/angular-sdk-components/src/lib/_components/widget/attachment/AttachmentUtils.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ export const updateReduxState = (
126126
valueRef: string,
127127
options: PageInstructionOptions
128128
) => {
129-
const { allowMultiple, isOldAttachment, insertRedux, deleteRedux } = options;
130-
let deleteIndex = -1;
129+
const { allowMultiple, isOldAttachment, insertRedux, deleteRedux, deleteIndex } = options;
131130

132131
if (allowMultiple || isOldAttachment) {
133132
transformedAttachments.forEach(attachment => {
@@ -147,11 +146,6 @@ export const updateReduxState = (
147146
};
148147
PCore.getStore()?.dispatch(actionPayLoad);
149148
} else if (deleteRedux) {
150-
const uniqueKey = getMappedValue('pzInsKey');
151-
deleteIndex = existingAttachments.findIndex(
152-
existingAttachment =>
153-
existingAttachment[uniqueKey as keyof ReduxAttachments] === transformedAttachments[0][uniqueKey as keyof ReduxAttachments]
154-
);
155149
const actionPayLoad = {
156150
type: 'LIST_ACTION',
157151
payload: {

packages/angular-sdk-components/src/lib/_components/widget/attachment/attachment.component.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,12 @@ export class AttachmentComponent implements OnInit, OnDestroy {
339339

340340
populateErrorAndUpdateRedux(file) {
341341
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);
342348
// set errors to property to block submit even on errors in file upload
343349
PCore.getMessageManager().addMessages({
344350
messages: [
@@ -351,12 +357,6 @@ export class AttachmentComponent implements OnInit, OnDestroy {
351357
pageReference: this.pConn$.getPageReference(),
352358
context: this.contextName
353359
});
354-
insertAttachments([file], this.pConn$, this.multiAttachmentsInInlineEdit, {
355-
allowMultiple: this.allowMultiple$,
356-
isOldAttachment: this.isOldAttachment,
357-
isMultiAttachmentInInlineEditTable: this.isMultiAttachmentInInlineEditTable,
358-
attachmentCount: this.attachmentCount
359-
} as any);
360360
}
361361

362362
errorHandler(isFetchCanceled, file) {

0 commit comments

Comments
 (0)