mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-23 19:49:56 +01:00
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:
@@ -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":
|
||||
|
||||
Reference in New Issue
Block a user