diff --git a/app/client/src/sagas/layoutConversionSagas.ts b/app/client/src/sagas/layoutConversionSagas.ts index 370ab2d8e7..c5cd40c723 100644 --- a/app/client/src/sagas/layoutConversionSagas.ts +++ b/app/client/src/sagas/layoutConversionSagas.ts @@ -1,5 +1,6 @@ import { setLayoutConversionStateAction } from "actions/autoLayoutActions"; import { ReduxActionTypes } from "@appsmith/constants/ReduxActionConstants"; +import type { Page } from "@appsmith/constants/ReduxActionConstants"; import type { ReduxAction } from "@appsmith/constants/ReduxActionConstants"; import type { AppState } from "@appsmith/reducers"; import { MAIN_CONTAINER_WIDGET_ID } from "constants/WidgetConstants"; @@ -21,7 +22,10 @@ import * as Sentry from "@sentry/react"; import log from "loglevel"; import { saveAllPagesSaga } from "./PageSagas"; import { updateApplicationLayout } from "@appsmith/actions/applicationActions"; -import { getCurrentApplicationId } from "selectors/editorSelectors"; +import { + getCurrentApplicationId, + getPageList, +} from "selectors/editorSelectors"; import { updateApplicationLayoutType } from "./AutoLayoutUpdateSagas"; import AnalyticsUtil from "utils/AnalyticsUtil"; @@ -33,9 +37,11 @@ function* convertFromAutoToFixedSaga(action: ReduxAction) { let appId = ""; let snapshotSaveSuccess = false; try { - appId = yield select(getCurrentApplicationId); + const pageList: Page[] = yield select(getPageList); const pageWidgetsList: PageWidgetsReduxState = yield select(getPageWidgets); + appId = yield select(getCurrentApplicationId); + const notEmptyApp = isNotEmptyApp(pageWidgetsList); if (notEmptyApp) { @@ -55,8 +61,9 @@ function* convertFromAutoToFixedSaga(action: ReduxAction) { const pageLayouts = []; //Convert all the pages into Fixed layout by iterating over the list - for (const [pageId, page] of Object.entries(pageWidgetsList)) { - const { dsl: normalizedDSL, layoutId } = page; + for (const page of pageList) { + const pageId = page?.pageId; + const { dsl: normalizedDSL, layoutId } = pageWidgetsList[pageId]; const fixedLayoutDSL = convertNormalizedDSLToFixed( normalizedDSL, @@ -120,9 +127,11 @@ function* convertFromFixedToAutoSaga() { let appId = ""; let snapshotSaveSuccess = false; try { - appId = yield select(getCurrentApplicationId); + const pageList: Page[] = yield select(getPageList); const pageWidgetsList: PageWidgetsReduxState = yield select(getPageWidgets); + appId = yield select(getCurrentApplicationId); + const notEmptyApp = isNotEmptyApp(pageWidgetsList); if (notEmptyApp) { @@ -141,8 +150,9 @@ function* convertFromFixedToAutoSaga() { const pageLayouts = []; - for (const [pageId, page] of Object.entries(pageWidgetsList)) { - const { dsl: normalizedDSL, layoutId } = page; + for (const page of pageList) { + const pageId = page?.pageId; + const { dsl: normalizedDSL, layoutId } = pageWidgetsList[pageId]; const fixedDSL: DSLWidget = CanvasWidgetsNormalizer.denormalize( MAIN_CONTAINER_WIDGET_ID, diff --git a/app/client/src/utils/DSLConversions/fixedToAutoLayout.ts b/app/client/src/utils/DSLConversions/fixedToAutoLayout.ts index a5971e9514..2b2d6175c4 100644 --- a/app/client/src/utils/DSLConversions/fixedToAutoLayout.ts +++ b/app/client/src/utils/DSLConversions/fixedToAutoLayout.ts @@ -3,7 +3,7 @@ import { layoutConfigurations, MAIN_CONTAINER_WIDGET_ID, } from "constants/WidgetConstants"; -import { partition } from "lodash"; +import { get, partition } from "lodash"; import CanvasWidgetsNormalizer from "normalizers/CanvasWidgetsNormalizer"; import type { FlexLayer } from "utils/autoLayout/autoLayoutTypes"; import { alterLayoutForDesktop } from "utils/autoLayout/AutoLayoutUtils"; @@ -822,10 +822,8 @@ function verifyDynamicPathBindingList( const dynamicBindingPathList: DynamicPath[] = []; for (const dynamicBindingPath of widget.dynamicBindingPathList) { //if the values are not dynamic, remove from the dynamic binding path list - if ( - !widget[dynamicBindingPath.key] || - !isDynamicValue(widget[dynamicBindingPath.key]) - ) { + const dynamicValue = get(widget, dynamicBindingPath.key); + if (!dynamicValue || !isDynamicValue(dynamicValue)) { continue; }