From 64116583e366af4c5a4afa8fdc1745b87152cfae Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Fri, 19 Mar 2021 11:39:35 +0530 Subject: [PATCH] Fix container widget dynamicBindingPathList correction (#3619) --- app/client/src/sagas/PageSagas.tsx | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/app/client/src/sagas/PageSagas.tsx b/app/client/src/sagas/PageSagas.tsx index fa37f695cd..6a31c101cb 100644 --- a/app/client/src/sagas/PageSagas.tsx +++ b/app/client/src/sagas/PageSagas.tsx @@ -365,7 +365,7 @@ function* savePageSaga(action: ReduxAction<{ isRetry?: boolean }>) { if (error instanceof IncorrectBindingError) { const { isRetry } = action.payload; const incorrectBindingError = JSON.parse(error.message); - const { widgetId, message } = incorrectBindingError; + const { message } = incorrectBindingError; if (isRetry) { Sentry.captureException(new Error("Failed to correct binding paths")); yield put({ @@ -379,18 +379,23 @@ function* savePageSaga(action: ReduxAction<{ isRetry?: boolean }>) { }, }); } else { - const correctedWidget = migrateIncorrectDynamicBindingPathLists( - widgets[widgetId], + // Create a denormalized structure because the migration needs the children in the dsl form + const denormalizedWidgets = CanvasWidgetsNormalizer.denormalize("0", { + canvasWidgets: widgets, + }); + const correctedWidgets = migrateIncorrectDynamicBindingPathLists( + denormalizedWidgets, + ); + // Normalize the widgets because the save page needs it in the flat structure + const normalizedWidgets = CanvasWidgetsNormalizer.normalize( + correctedWidgets, ); AnalyticsUtil.logEvent("CORRECT_BAD_BINDING", { error: error.message, - correctWidget: JSON.stringify(correctedWidget), + correctWidget: JSON.stringify(normalizedWidgets), }); yield put( - updateAndSaveLayout( - { ...widgets, [widgetId]: correctedWidget }, - true, - ), + updateAndSaveLayout(normalizedWidgets.entities.canvasWidgets, true), ); } }