Canvas: Fix canvas style regression (#87363)

This commit is contained in:
Nathan Marrs 2024-05-03 17:47:30 -06:00 committed by GitHub
parent 1ef1cc7e3f
commit 5e4722fe2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 6 deletions

View File

@ -2195,7 +2195,12 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use export all (\`export * from ...\`)", "3"]
],
"public/app/features/canvas/runtime/element.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Do not use any type assertions.", "3"],
[0, 0, 0, "Do not use any type assertions.", "4"],
[0, 0, 0, "Do not use any type assertions.", "5"]
],
"public/app/features/canvas/runtime/frame.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]

View File

@ -191,16 +191,18 @@ export class ElementState implements LayerElement {
this.sizeStyle = style;
if (this.div) {
for (const [key, value] of Object.entries(this.sizeStyle)) {
this.div.style.setProperty(key, value);
for (const key in this.sizeStyle) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
this.div.style[key as any] = (this.sizeStyle as any)[key];
}
// TODO: This is a hack, we should have a better way to handle this
const elementType = this.options.type;
if (!SVGElements.has(elementType)) {
// apply styles to div if it's not an SVG element
for (const [key, value] of Object.entries(this.dataStyle)) {
this.div.style.setProperty(key, value);
for (const key in this.dataStyle) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
this.div.style[key as any] = (this.dataStyle as any)[key];
}
} else {
// ELEMENT IS SVG
@ -209,7 +211,8 @@ export class ElementState implements LayerElement {
// wrapper div element (this.div) doesn't re-render (has static `key` property),
// so we have to clean styles manually;
for (const key in this.dataStyle) {
this.div.style.removeProperty(key);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
this.div.style[key as any] = '';
}
}
}