From 271dbbe90086e95e623b71964a35cbea9d38bfdf Mon Sep 17 00:00:00 2001 From: "Michael S. molina" Date: Wed, 29 Mar 2023 12:04:08 -0300 Subject: [PATCH] Deep clones layout object --- .../src/dashboard/util/updateComponentParentsList.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/superset-frontend/src/dashboard/util/updateComponentParentsList.js b/superset-frontend/src/dashboard/util/updateComponentParentsList.js index 57602d303d491..aac4a0579020d 100644 --- a/superset-frontend/src/dashboard/util/updateComponentParentsList.js +++ b/superset-frontend/src/dashboard/util/updateComponentParentsList.js @@ -17,6 +17,7 @@ * under the License. */ import { logging } from '@superset-ui/core'; +import { cloneDeep } from 'lodash'; export default function updateComponentParentsList({ currentComponent, @@ -33,10 +34,13 @@ export default function updateComponentParentsList({ if (Array.isArray(currentComponent.children)) { currentComponent.children.forEach(childId => { if (layout[childId]) { + // We need to clone to avoid mutating Redux state + const child = cloneDeep(layout[childId]); + child.parents = parentsList; // eslint-disable-next-line no-param-reassign - layout[childId] = { ...layout[childId], parents: parentsList }; + layout[childId] = child; updateComponentParentsList({ - currentComponent: layout[childId], + currentComponent: child, layout, }); } else {