ToolbarHUD.setHotkeys ignores removed keys so captions stay stale #1089

Closed
opened 2026-08-13 13:55:59 +00:00 by spikerj · 1 comment
Owner

Found while adding Wave 8 leftover coverage for toolbar-hud.ts.

setHotkeys only treats the map as changed when a key present in the new map differs:

const changed = Object.keys(map).some((k) => this.hotkeys[k] !== map[k]);
if (!changed) return;
this.hotkeys = { ...map };

Dropping a binding while the remaining labels are unchanged is a no-op. Example:

  • setHotkeys({ toggleScore: "P", toggleMinimap: "M" }) paints [P] [M]
  • setHotkeys({ toggleScore: "P" }) returns early because toggleScore still equals "P"
  • minimap caption stays [M] instead of falling back to [?]

pushToolbarHotkeys() always sends the full 8-action map, so this is latent unless a caller (or a future partial update) omits a key. Rebinding that changes a value still works.

Suggested fix: also treat a key-set mismatch as a change (Object.keys(this.hotkeys).length !== Object.keys(map).length or a two-way diff), then rebuild captions from { ...map } as today.

Found while adding Wave 8 leftover coverage for `toolbar-hud.ts`. `setHotkeys` only treats the map as changed when **a key present in the new map** differs: ```ts const changed = Object.keys(map).some((k) => this.hotkeys[k] !== map[k]); if (!changed) return; this.hotkeys = { ...map }; ``` Dropping a binding while the remaining labels are unchanged is a no-op. Example: - `setHotkeys({ toggleScore: "P", toggleMinimap: "M" })` paints `[P]` `[M]` - `setHotkeys({ toggleScore: "P" })` returns early because `toggleScore` still equals `"P"` - minimap caption stays `[M]` instead of falling back to `[?]` `pushToolbarHotkeys()` always sends the full 8-action map, so this is latent unless a caller (or a future partial update) omits a key. Rebinding that *changes* a value still works. Suggested fix: also treat a key-set mismatch as a change (`Object.keys(this.hotkeys).length !== Object.keys(map).length` or a two-way diff), then rebuild captions from `{ ...map }` as today.
Author
Owner

Fixed in spikersoft-angular PR #823 (a0f0ccd9). Closing.

Fixed in `spikersoft-angular` [PR #823](https://git.spikersoft.com/spikerj/spikersoft-angular/pulls/823) (`a0f0ccd9`). Closing.
Sign in to join this conversation.