Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(sdk): declare ThemeStyle's fields so themed widgets validate

esengineddb1f5e442cd
diff --git a/sdk/src/ui/theme/theme-style.ts b/sdk/src/ui/theme/theme-style.ts
index 2c979d09a..9db694336 100644
--- a/sdk/src/ui/theme/theme-style.ts
+++ b/sdk/src/ui/theme/theme-style.ts
@@ -30,8 +30,15 @@ export interface ThemeStyleData {
}
// Runtime-only: a widget's theme-role tags are re-derived from code on every
-// construct, never persisted — so it stays out of scenes and prefabs.
-export const ThemeStyle = defineComponent<ThemeStyleData>('ThemeStyle', {}, { transient: true });
+// construct, never persisted — so it stays out of scenes and prefabs. The default
+// DECLARES the fields (even though all are optional): `insert` validates data
+// against the schema's keys, so an empty default would reject every role a widget
+// tags (e.g. a dialog's `{ visual: 'backdrop' }`).
+export const ThemeStyle = defineComponent<ThemeStyleData>(
+ 'ThemeStyle',
+ { visual: undefined, text: undefined, states: {} },
+ { transient: true },
+);
/** Tag `entity` so the active theme's colors re-resolve onto it (see
* `applyThemeToWorld`). */