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): blur removed text input surfaces
yhh3b705f8ab65a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8a41a7196..cfb92f48e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,6 +16,8 @@ published separately; it ships inside the editor.### Fixed+- **Removed text fields release OS input focus.** Deleting the focused entity or removing its TextInput component closes the editing surface even though the old component can no longer be updated.+- **Text input surfaces stay with their own apps.** Closing an older app or a preview removes its own text-editor listeners and surface, preserving typing in other running apps. Repeated cleanup releases each surface once.- **Tilemap atlas and grid edits refresh cached meshes.** Changing columns, texture dimensions, atlas borders or grid layout updates UVs and geometry without repainting tile data. Cached meshes now compare their resolved layout inputs, while unchanged inputs retain their geometry; editor pixel checks compare live edits with a fresh repaint.diff --git a/sdk/src/ui/text/text-input-plugin.ts b/sdk/src/ui/text/text-input-plugin.tsindex 97a81b4a5..f6128bd5c 100644--- a/sdk/src/ui/text/text-input-plugin.ts+++ b/sdk/src/ui/text/text-input-plugin.ts@@ -337,9 +337,10 @@ export class TextInputPlugin implements Plugin {// Only a field that really lost focus is blurred. Re-attaching// an editor to the field that already has focus must not blur// the surface on its way in.- if (prevFocusedTextInput !== null && prevFocusedTextInput !== currentFocused- && world.valid(prevFocusedTextInput) && world.has(prevFocusedTextInput, TextInput)) {- world.update(prevFocusedTextInput, TextInput, (ti) => { ti.focused = false; });+ if (prevFocusedTextInput !== null && prevFocusedTextInput !== currentFocused) {+ if (world.valid(prevFocusedTextInput) && world.has(prevFocusedTextInput, TextInput)) {+ world.update(prevFocusedTextInput, TextInput, (ti) => { ti.focused = false; });+ }editor.blur();}diff --git a/sdk/tests/text-input-plugin-lifecycle.test.ts b/sdk/tests/text-input-plugin-lifecycle.test.tsindex 048ef9c9c..868ae23eb 100644--- a/sdk/tests/text-input-plugin-lifecycle.test.ts+++ b/sdk/tests/text-input-plugin-lifecycle.test.ts@@ -2,6 +2,7 @@// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Teamimport { afterEach, expect, it, vi } from 'vitest';import type { TextEditorEvent } from '../src/platform/types';+import { bootMockApp } from './helpers/mockApp';const surfaces: ReturnType<typeof createSurface>[] = [];function createSurface() {@@ -32,7 +33,7 @@ const { UIEvents, UIEventQueue } = await import('../src/ui/core/events');const { TextInput } = await import('../src/ui/text/text-input');const apps: ReturnType<typeof App.new>[] = [];function build(plugin: InstanceType<typeof TextInputPlugin>) {- const app = App.new();+ const app = bootMockApp().app;apps.push(app);app.addPlugin({ name: 'focus', build(app) {app.insertResource(FocusManager, new FocusManagerState());@@ -96,3 +97,25 @@ it('cleanup without an app releases every remaining surface exactly once', () =>expect(surface.listeners.size).toBe(0);}});++it.each(['despawn', 'remove'] as const)('blurs the OS surface when the focused field is %s', async removal => {+ const app = build(new TextInputPlugin());+ const field = app.world.spawn();+ app.world.insert(field, TextInput, { value: '' });+ app.getResource(FocusManager).focus(field);+ await app.tick(1 / 60);+ expect(surfaces[0].focus).toHaveBeenCalledOnce();+ if (removal === 'despawn') app.world.despawn(field);+ else app.world.remove(field, TextInput);+ await app.tick(1 / 60);+ expect(surfaces[0].blur).toHaveBeenCalledOnce();+ await app.tick(1 / 60);+ expect(surfaces[0].blur).toHaveBeenCalledOnce();+ const next = app.world.spawn();+ app.world.insert(next, TextInput, { value: '' });+ app.getResource(FocusManager).focus(next);+ 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(next, TextInput).value).toBe('typed');+});diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex 8886424b7..3751546bc 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): blur removed text input surfaces':+ { note: 'Removed text fields release OS input focus.' },'fix(ui): isolate text input cleanup per app':{ note: 'Text input surfaces stay with their own apps.' },'fix(render): refresh tilemap meshes after layout changes':