From d6d373b52c0fc0f580e083a99483a5e79868869c Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 14 Sep 2024 02:22:21 +0530 Subject: [PATCH] feat: handle discarded steps in add list step --- src/context/browserSteps.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/context/browserSteps.tsx b/src/context/browserSteps.tsx index 65f25d8b..74f3cceb 100644 --- a/src/context/browserSteps.tsx +++ b/src/context/browserSteps.tsx @@ -65,12 +65,19 @@ export const BrowserStepsProvider: React.FC<{ children: React.ReactNode }> = ({ step => step.type === 'list' && step.id === listId ); if (existingListStepIndex !== -1) { - // Update the existing ListStep with new fields + // Update the existing ListStep with new fields, excluding discarded ones const updatedSteps = [...prevSteps]; const existingListStep = updatedSteps[existingListStepIndex] as ListStep; + const filteredNewFields = Object.entries(newFields).reduce((acc, [key, value]) => { + if (!discardedFields.has(`${listId}-${key}`)) { + acc[key] = value; + } + return acc; + }, {} as { [key: string]: TextStep }); + updatedSteps[existingListStepIndex] = { ...existingListStep, - fields: { ...existingListStep.fields, ...newFields }, + fields: { ...existingListStep.fields, ...filteredNewFields }, pagination: pagination, limit: limit, }; @@ -84,7 +91,6 @@ export const BrowserStepsProvider: React.FC<{ children: React.ReactNode }> = ({ } }); }; - const addScreenshotStep = (fullPage: boolean) => { setBrowserSteps(prevSteps => [ ...prevSteps,