Canvas: Fix inconsistent element placement when changing element type (#74942)

Co-authored-by: Nathan Marrs <nathanielmarrs@gmail.com>
This commit is contained in:
Linghao Su
2023-09-21 23:36:02 +03:00
committed by GitHub
co-authored by Nathan Marrs
parent 925f12d0ea
commit b5da762477
4 changed files with 18 additions and 12 deletions
@@ -83,8 +83,10 @@ export const buttonItem: CanvasElementItem<ButtonConfig, ButtonData> = {
},
},
placement: {
top: 100,
left: 100,
width: options?.placement?.width,
height: options?.placement?.height,
top: options?.placement?.top ?? 100,
left: options?.placement?.left ?? 100,
},
}),
+6 -6
View File
@@ -58,12 +58,6 @@ export const iconItem: CanvasElementItem<IconConfig, IconData> = {
display: IconDisplay,
getNewOptions: (options) => ({
placement: {
width: 100,
height: 100,
top: 0,
left: 0,
},
...options,
config: {
path: {
@@ -77,6 +71,12 @@ export const iconItem: CanvasElementItem<IconConfig, IconData> = {
fixed: 'transparent',
},
},
placement: {
width: options?.placement?.width ?? 100,
height: options?.placement?.height ?? 100,
top: options?.placement?.top ?? 100,
left: options?.placement?.left ?? 100,
},
}),
// Called when data changes
@@ -164,8 +164,10 @@ export const metricValueItem: CanvasElementItem<TextConfig, TextData> = {
},
},
placement: {
top: 100,
left: 100,
width: options?.placement?.width,
height: options?.placement?.height,
top: options?.placement?.top ?? 100,
left: options?.placement?.left ?? 100,
},
}),
+4 -2
View File
@@ -142,8 +142,10 @@ export const textItem: CanvasElementItem<TextConfig, TextData> = {
size: 16,
},
placement: {
top: 100,
left: 100,
width: options?.placement?.width ?? 100,
height: options?.placement?.height ?? 100,
top: options?.placement?.top,
left: options?.placement?.left,
},
}),