fix: unable to change zoom level back to 1.0 (#9283)

Fixed two issues with number input settings:

1. Added onBlur handler to immediately commit values when user
   clicks away, bypassing the 500ms debounce delay. This ensures
   values are saved even if the user navigates away quickly.

2. Added key prop based on current value to force re-render
   when the stored value changes, ensuring the input always
   reflects the actual persisted value.

Fixes #4035
This commit is contained in:
little Kitchen
2026-02-02 00:05:24 -08:00
committed by GitHub
parent a836642d74
commit 7001f98353

View File

@@ -581,6 +581,7 @@ function SettingItem(props: { item: Setting }) {
case "input":
return component.inputType === "number" ? (
<Input
key={component.defaultValue()}
type={"number"}
min={component.min}
max={component.max}
@@ -597,6 +598,16 @@ function SettingItem(props: { item: Setting }) {
: value;
component.onChange(value);
}, 500)}
onBlur={(e) => {
let value = e.target.valueAsNumber;
value =
Number.isNaN(value) || value < component.min
? component.min
: value > component.max
? component.max
: value;
component.onChange(value);
}}
/>
) : (
<Input
@@ -607,6 +618,7 @@ function SettingItem(props: { item: Setting }) {
(e) => component.onChange(e.target.value),
500
)}
onBlur={(e) => component.onChange(e.target.value)}
/>
);
case "icon":