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-22 04:36:02 +08:00 committed by GitHub
parent 925f12d0ea
commit b5da762477
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 12 deletions

View File

@ -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,
},
}),

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

View File

@ -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,
},
}),

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,
},
}),