NameModalHUD language change wipes the typed player name #1077

Closed
opened 2026-08-13 13:33:31 +00:00 by spikerj · 1 comment
Owner

While covering NameModalHUD (Wave 8 a5, tests only) the language-change paths were compared to resize().

What happens: setLanguage() (called every frame from updateModalHUDs when the code actually changes) and the language hit-mesh in handleClick both do clearGroup() + buildUI() without saving the live HUDTextInput value. buildUI() disposes the old input and constructs a new empty one. resize() already avoids this with _restoreName.

User-visible: typing a name, then clicking the language row (or a parent calling setLanguage("es")) clears the field and greys Confirm. The per-frame idempotent guard stops 60 Hz rebuilds, but a real en↔es change still wipes the name.

Fix: capture this.nameInput?.getValue() into _restoreName before dispose/rebuild in setLanguage and the language-click branch, the same way resize does.

Repro (jsdom): new NameModalHUD(800,600); hud.setPlayerName("Ada"); hud.setLanguage("es"); → getPlayerName() is "".

File: projects/spikersoft/src/app/_components/_games/dungeon-crawler/hud/name-modal-hud.ts

While covering `NameModalHUD` (Wave 8 a5, tests only) the language-change paths were compared to `resize()`. **What happens:** `setLanguage()` (called every frame from `updateModalHUDs` when the code actually changes) and the language hit-mesh in `handleClick` both do `clearGroup()` + `buildUI()` without saving the live `HUDTextInput` value. `buildUI()` disposes the old input and constructs a new empty one. `resize()` already avoids this with `_restoreName`. **User-visible:** typing a name, then clicking the language row (or a parent calling `setLanguage("es")`) clears the field and greys Confirm. The per-frame idempotent guard stops 60 Hz rebuilds, but a real en↔es change still wipes the name. **Fix:** capture `this.nameInput?.getValue()` into `_restoreName` before dispose/rebuild in `setLanguage` and the language-click branch, the same way `resize` does. **Repro (jsdom):** `new NameModalHUD(800,600); hud.setPlayerName("Ada"); hud.setLanguage("es");` → `getPlayerName()` is `""`. File: `projects/spikersoft/src/app/_components/_games/dungeon-crawler/hud/name-modal-hud.ts`
Author
Owner

Resolved in spikersoft-angular PR #819 (merged to master). NameModalHUD language change keeps the typed player name. Closing.

Resolved in spikersoft-angular [PR #819](https://git.spikersoft.com/spikerj/spikersoft-angular/pulls/819) (merged to `master`). NameModalHUD language change keeps the typed player name. Closing.
Sign in to join this conversation.