Skip to content

Commit

Permalink
Deep clones layout object
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina committed Mar 29, 2023
1 parent e20f424 commit 271dbbe
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/
import { logging } from '@superset-ui/core';
import { cloneDeep } from 'lodash';

export default function updateComponentParentsList({
currentComponent,
Expand All @@ -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 {
Expand Down

0 comments on commit 271dbbe

Please sign in to comment.