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.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(ui): bind field rendering to the active editing owner
yhh9320aa0d3a23
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ebb1fc3e2..c6c5ad330 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,6 +16,8 @@ published separately; it ships inside the editor.### Fixed+- **Text fields read only the editing surface they actually own.** Newly focused fields retain their committed display until attached, and read-only fields never borrow a previous field's transient value. Switching a live field to read-only detaches the OS surface and hides its caret; restoring editability reattaches the committed value without replaying rejected input.+- **Grid path searches reuse their working memory.** Repeated queries reuse per-grid score, parent, visitation and heap storage instead of allocating map-sized buffers each time. Search stamps isolate queries, nested searches receive separate storage, exceptions release leases, and returned routes remain caller-owned. Weighted paths, snapping and best-effort endpoints retain their behavior.- **Native text measurement wraps without rescanning growing prefixes.** The public measurement path appends ordered glyph advances through the shared greedy wrapper, avoiding quadratic cache queries and repeated host rasterization when long text exceeds the bounded working set. Whitespace, supplementary characters and signed spacing keep existing line breaks and metrics; Canvas retains whole-string measurement for non-additive typography.diff --git a/sdk/src/ui/text/text-input-plugin.ts b/sdk/src/ui/text/text-input-plugin.tsindex c08cc1640..9cc071aa0 100644--- a/sdk/src/ui/text/text-input-plugin.ts+++ b/sdk/src/ui/text/text-input-plugin.ts@@ -115,6 +115,7 @@ export class TextInputPlugin implements Plugin {if (!fm || fm.focusedEntity === null) return null;const entity = fm.focusedEntity;if (!world.isEntityActive(entity) || !world.has(entity, TextInput)) return null;+ if (world.get(entity, TextInput).readOnly) return null;if (world.has(entity, Interactable) && !world.get(entity, Interactable).enabled) return null;return entity;}@@ -414,7 +415,7 @@ export class TextInputPlugin implements Plugin {lastTime = now;dt = Math.min(dt, 0.1);- const focused = getFocusedTextInput();+ const focused = getEditingTextInput();if (focused !== null) {cursorTimer += dt;if (cursorTimer >= CURSOR_BLINK_INTERVAL) {@@ -517,7 +518,7 @@ export class TextInputPlugin implements Plugin {syncSelChild(ch.sel, ti, sshow, sx, stop, sw);syncTextChild(ch.text, ti, disp, innerW, scrollX, ao);// The blinking caret hides while a highlight is drawn.- syncCaretChild(ch.caret, ti, caretX, caretTop, ti.focused && cursorVisible && !sshow);+ syncCaretChild(ch.caret, ti, caretX, caretTop, editing && ti.focused && cursorVisible && !sshow);// Anchor the IME at the caret. Not while composing — moving it// mid-composition would yank an open candidate window.diff --git a/sdk/tests/text-input-plugin-lifecycle.test.ts b/sdk/tests/text-input-plugin-lifecycle.test.tsindex 6611656a9..0da5352ca 100644--- a/sdk/tests/text-input-plugin-lifecycle.test.ts+++ b/sdk/tests/text-input-plugin-lifecycle.test.ts@@ -47,6 +47,7 @@ const { TextInputPlugin } = await import('../src/ui/text/text-input-plugin');const { FocusManager, FocusManagerState } = await import('../src/ui/input/focusable');const { UIEvents, UIEventQueue } = await import('../src/ui/core/events');const { TextInput } = await import('../src/ui/text/text-input');+const { Text } = await import('../src/ui/core/text');const { defineSystem, Schedule } = await import('../src/ecs/system');const { Disabled, Transform } = await import('../src/ecs/component');const { UINode } = await import('../src/ui/core/ui-node');@@ -229,3 +230,55 @@ it('releases each App measurement atlas without disposing the newer field atlas'second.quit();expect(measurements[1].dispose).toHaveBeenCalledOnce();});++it('renders a focused read-only field from its own value without reading the unattached editor', async () => {+ dimensions.width.mockReturnValue(160);+ dimensions.height.mockReturnValue(40);+ const app = build(new TextInputPlugin());+ const field = app.world.spawn();+ app.world.insert(field, Transform, {});+ app.world.insert(field, UINode, {});+ app.world.insert(field, TextInput, { value: 'locked value', readOnly: true });+ app.getResource(FocusManager).focus(field);+ await app.tick(1 / 60);+ const texts = app.world.getEntitiesWithComponents([Text]).map(e => app.world.get(e, Text).content);+ expect(texts).toEqual(['locked value']);+ expect(surfaces[0].focus).not.toHaveBeenCalled();+ expect(app.world.get(field, TextInput).focused).toBe(false);+});++it('detaches the editing surface on a read-only transition and reattaches when editing returns', async () => {+ const app = build(new TextInputPlugin());+ const field = app.world.spawn();+ app.world.insert(field, TextInput, { value: 'original' });+ app.getResource(FocusManager).focus(field);+ await app.tick(1 / 60);+ app.world.update(field, TextInput, ti => { ti.readOnly = true; });+ for (const listener of surfaces[0].listeners) listener({ kind: 'change' });+ expect(app.world.get(field, TextInput).value).toBe('original');+ await app.tick(1 / 60);+ expect(surfaces[0].blur).toHaveBeenCalledOnce();+ expect(app.world.get(field, TextInput).focused).toBe(false);+ expect(app.getResource(FocusManager).focusedEntity).toBe(field);+ app.world.update(field, TextInput, ti => { ti.readOnly = false; });+ await app.tick(1 / 60);+ expect(surfaces[0].focus).toHaveBeenCalledTimes(2);+ for (const listener of surfaces[0].listeners) listener({ kind: 'change' });+ expect(app.world.get(field, TextInput).value).toBe('typed');+});++it('renders a newly focused field from its value until the surface is attached', async () => {+ dimensions.width.mockReturnValue(160);+ dimensions.height.mockReturnValue(40);+ const app = build(new TextInputPlugin());+ const field = app.world.spawn();+ app.world.insert(field, Transform, {});+ app.world.insert(field, UINode, {});+ app.world.insert(field, TextInput, { value: 'new field' });+ app.getResource(FocusManager).focus(field);+ await app.tick(1 / 60);+ expect(app.world.getEntitiesWithComponents([Text]).map(e => app.world.get(e, Text).content)).toEqual(['new field']);+ expect(surfaces[0].focus).toHaveBeenCalledOnce();+ await app.tick(1 / 60);+ expect(app.world.getEntitiesWithComponents([Text]).map(e => app.world.get(e, Text).content)).toEqual(['typed']);+});diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex c9bec1890..bf937be54 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -28,6 +28,8 @@ export const NOTES_FLOOR = 'v0.65.0';* the reader recognises anyway.*/export const NOTED = {+ 'fix(ui): bind field rendering to the active editing owner':+ { note: 'Text fields read only the editing surface they actually own.' },'feat(editor): inspect live agent route failures on demand':{ note: "Inspect a live agent's current route on demand." },'feat(inspector): inspect live agent route failures on demand':