From 918c79d71ccae5825014fbaa2b1b4c76541da953 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 21 Sep 2024 15:57:44 +0530 Subject: [PATCH] feat: ensure list ids and labels are updated --- src/context/browserSteps.tsx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/context/browserSteps.tsx b/src/context/browserSteps.tsx index 9759ea75..7630f559 100644 --- a/src/context/browserSteps.tsx +++ b/src/context/browserSteps.tsx @@ -61,13 +61,11 @@ export const BrowserStepsProvider: React.FC<{ children: React.ReactNode }> = ({ const addListStep = (listSelector: string, newFields: { [key: string]: TextStep }, listId: number, pagination?: { type: string; selector: string }, limit?: number) => { setBrowserSteps(prevSteps => { - const existingListStepIndex = prevSteps.findIndex( - step => step.type === 'list' && step.id === listId - ); + const existingListStepIndex = prevSteps.findIndex(step => step.type === 'list' && step.id === listId); if (existingListStepIndex !== -1) { - // 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; @@ -134,7 +132,6 @@ export const BrowserStepsProvider: React.FC<{ children: React.ReactNode }> = ({ ); }; - const removeListTextField = (listId: number, fieldKey: string) => { setBrowserSteps(prevSteps => prevSteps.map(step => {