-
Notifications
You must be signed in to change notification settings - Fork 4.6k
chore: fix blueprint operation inconsistency for zone #36980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
311aae8
d7b7cf5
d36fa97
76a6df8
26279c8
8a385ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ import { addNewAnvilWidgetToDSL } from "layoutSystems/anvil/integrations/sagas/a | |
| export function* createSectionAndAddWidget( | ||
| allWidgets: CanvasWidgetsReduxState, | ||
| highlight: AnvilHighlightInfo, | ||
| widgets: WidgetLayoutProps[], | ||
| draggedWidgets: WidgetLayoutProps[], | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. used better contextual name to avoid confusion. |
||
| parentId: string, | ||
| ) { | ||
| /** | ||
|
|
@@ -48,7 +48,7 @@ export function* createSectionAndAddWidget( | |
| yield call( | ||
| addWidgetsToSection, | ||
| updatedWidgets, | ||
| widgets, | ||
| draggedWidgets, | ||
| highlight, | ||
| sectionProps, | ||
| ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,7 +58,7 @@ export function* createZoneAndAddWidgets( | |
| updatedWidgets, | ||
| draggedWidgets, | ||
| highlight, | ||
| zoneProps, | ||
| zoneProps.widgetId, | ||
| ); | ||
|
|
||
| return res; | ||
|
|
@@ -68,13 +68,11 @@ export function* addWidgetsToZone( | |
| allWidgets: CanvasWidgetsReduxState, | ||
| draggedWidgets: WidgetLayoutProps[], | ||
| highlight: AnvilHighlightInfo, | ||
| zone: WidgetProps, | ||
| zoneWidgetId: string, | ||
| ) { | ||
| let updatedWidgets: CanvasWidgetsReduxState = { ...allWidgets }; | ||
| const zoneProps = { ...zone }; | ||
| const preset: LayoutProps[] = zoneProps.layout; | ||
| const preset: LayoutProps[] = updatedWidgets[zoneWidgetId].layout; | ||
| let zoneLayout: LayoutProps = preset[0]; | ||
| const { widgetId: zoneWidgetId } = zoneProps; | ||
|
|
||
| /** | ||
| * If dragged widget is a new widget, | ||
|
|
@@ -86,7 +84,7 @@ export function* addWidgetsToZone( | |
| zoneWidgetId, | ||
| draggedWidgets, | ||
| ); | ||
| zoneProps.children = updatedWidgets[zoneWidgetId].children; | ||
| updatedWidgets[zoneWidgetId].children = updatedWidgets[zoneWidgetId].children; | ||
|
jsartisan marked this conversation as resolved.
Outdated
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the updateDraggedWidgets can update the zone in the blueprint operation as well, but we didn't use updatedWidgets's zone. We just worked on the zone that we got in params. |
||
|
|
||
| /** | ||
| * Split new widgets based on type. | ||
|
|
@@ -127,14 +125,11 @@ export function* addWidgetsToZone( | |
| /** | ||
| * Update zone widget with the updated preset. | ||
| */ | ||
| zoneProps.layout = [zoneLayout]; | ||
| updatedWidgets[zoneWidgetId].layout = [zoneLayout]; | ||
|
|
||
| return { | ||
| canvasWidgets: { | ||
| ...updatedWidgets, | ||
| [zoneProps.widgetId]: zoneProps, | ||
| }, | ||
| zone: zoneProps, | ||
| canvasWidgets: updatedWidgets, | ||
| zone: updatedWidgets[zoneWidgetId], | ||
| }; | ||
| } | ||
|
|
||
|
|
@@ -219,7 +214,7 @@ function* moveWidgetsToNewLayout( | |
| widgets, | ||
| transformMovedWidgets(widgets, movedWidgets, highlight), | ||
| highlight, | ||
| zone, | ||
| zone.widgetId, | ||
| ); | ||
|
|
||
| return canvasWidgets; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -134,8 +134,10 @@ export function* executeWidgetBlueprintOperations( | |
|
|
||
| updatePropertyPayloads && | ||
| updatePropertyPayloads.forEach((params: UpdatePropertyArgs) => { | ||
| widgets[params.widgetId][params.propertyName] = | ||
| params.propertyValue; | ||
| widgets[params.widgetId] = { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For cases where widgets are already present in redux, the objects are frozen and the fields are readonly. So we couldn't update them. used the spread operator to bypass that. Hoping this won't cause any issue. |
||
| ...widgets[params.widgetId], | ||
| [params.propertyName]: params.propertyValue, | ||
| }; | ||
| }); | ||
| break; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.