From 70767d254134a3a649eacd5c0cee96bb472d23d7 Mon Sep 17 00:00:00 2001 From: VectorSophie <161856415+VectorSophie@users.noreply.github.com> Date: Sun, 4 Jan 2026 13:07:13 +0900 Subject: [PATCH] Fluentslider rapid-fire bug fix (#2778) ## Description: Describe the PR. Modified FluentSlider(my code) to split number input handle to visual update(NumberInput) and dispatch value(NumberComplete) updated the event flow to match them, will fix rapid-fire updates that seemed to glitch bots out. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: jackochess --- src/client/LocalServer.ts | 5 ++++- src/client/components/FluentSlider.ts | 19 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/client/LocalServer.ts b/src/client/LocalServer.ts index 100bbc3f9..2514dc695 100644 --- a/src/client/LocalServer.ts +++ b/src/client/LocalServer.ts @@ -132,7 +132,10 @@ export class LocalServer { if (!this.lobbyConfig.gameRecord) { if (clientMsg.turnNumber % 100 === 0) { // In singleplayer, only store hash every 100 turns to reduce size of game record. - this.turns[clientMsg.turnNumber].hash = clientMsg.hash; + const turn = this.turns[clientMsg.turnNumber]; + if (turn) { + turn.hash = clientMsg.hash; + } } return; } diff --git a/src/client/components/FluentSlider.ts b/src/client/components/FluentSlider.ts index 56957d49c..cf2dedd6f 100644 --- a/src/client/components/FluentSlider.ts +++ b/src/client/components/FluentSlider.ts @@ -84,7 +84,7 @@ export class FluentSlider extends LitElement { this.dispatchValueChange(); } - private handleNumberChange(e: Event) { + private handleNumberInput(e: Event) { const target = e.target as HTMLInputElement; let val = target.valueAsNumber; if (isNaN(val)) { @@ -93,11 +93,19 @@ export class FluentSlider extends LitElement { if (val < this.min) val = this.min; if (val > this.max) val = this.max; this.value = val; + // Don't dispatch value change on every input - only on blur/enter + } + + private handleNumberComplete() { + // Dispatch the value change when editing is complete this.dispatchValueChange(); } private handleNumberKeyDown(e: KeyboardEvent) { - if (e.key === "Enter") this.isEditing = false; + if (e.key === "Enter") { + this.isEditing = false; + this.handleNumberComplete(); + } } private enableEditing() { @@ -125,8 +133,11 @@ export class FluentSlider extends LitElement { .min=${this.min} .max=${this.max} .valueAsNumber=${this.value} - @input=${this.handleNumberChange} - @blur=${() => (this.isEditing = false)} + @input=${this.handleNumberInput} + @blur=${() => { + this.isEditing = false; + this.handleNumberComplete(); + }} @keydown=${this.handleNumberKeyDown} />` : html`