fix(qsolist): let the Max box be lowered
The input was bound straight to the number and committed on every keystroke, so
it could not be EMPTIED: clearing it yields "", Number("") is 0, 0 fails the
"> 0" guard, the state never moved, and value={qsoLimit} snapped the old figure
straight back. Going from 200000 down to 100 was a fight against the field — and
read as the setting refusing to persist, which it was not: writeUiPref stores it
and syncPortablePrefs makes the database authoritative at boot. It also wrote
the preference once per keystroke (1, then 10, then 100).
Raw text in local state, committed on blur or Enter, per the controlled-input
note in CLAUDE.md.
This commit is contained in:
+18
-5
@@ -1000,6 +1000,19 @@ export default function App() {
|
||||
return Number.isFinite(raw) && raw > 0 ? raw : 500;
|
||||
});
|
||||
useEffect(() => { writeUiPref('hamlog.qsoLimit', String(qsoLimit)); }, [qsoLimit]);
|
||||
// Raw text for the Max box, committed on blur/Enter — never per keystroke.
|
||||
// Bound straight to the number, the field could not be EMPTIED: clearing it
|
||||
// gives "", Number("") is 0, 0 fails the "> 0" test, so the state never moved
|
||||
// and value={qsoLimit} snapped the old number straight back. Going from 200000
|
||||
// to 100 was a fight against the input, and looked like the setting refusing
|
||||
// to stick. It also wrote the preference once per keystroke (1, 10, 100).
|
||||
const [qsoLimitText, setQsoLimitText] = useState(String(qsoLimit));
|
||||
useEffect(() => { setQsoLimitText(String(qsoLimit)); }, [qsoLimit]);
|
||||
const commitQsoLimit = () => {
|
||||
const n = Math.floor(Number(qsoLimitText));
|
||||
if (Number.isFinite(n) && n > 0) setQsoLimit(n);
|
||||
else setQsoLimitText(String(qsoLimit)); // nonsense typed → put the live value back
|
||||
};
|
||||
|
||||
// Contest session: load once, then persist on every change (merge + save).
|
||||
useEffect(() => {
|
||||
@@ -6286,11 +6299,11 @@ export default function App() {
|
||||
min={1}
|
||||
step={100}
|
||||
className="w-24 h-7 font-mono text-xs"
|
||||
value={qsoLimit}
|
||||
onChange={(e) => {
|
||||
const n = Number(e.target.value);
|
||||
if (Number.isFinite(n) && n > 0) setQsoLimit(Math.floor(n));
|
||||
}}
|
||||
value={qsoLimitText}
|
||||
onChange={(e) => setQsoLimitText(e.target.value)}
|
||||
onBlur={commitQsoLimit}
|
||||
onKeyDown={(e) => { if (e.key === 'Enter') (e.target as HTMLInputElement).blur(); }}
|
||||
title="Rows loaded into the list — press Enter to apply"
|
||||
/>
|
||||
<Button
|
||||
variant="ghost"
|
||||
|
||||
Reference in New Issue
Block a user