Run cargo fmt on the unit code and drop a quantity box's invalid mark when its line is removed
The new CI runs cargo fmt --check. QuantityInput also reported its validity only when it changed, so removing a line whose quantity box held bad text left that box counted as invalid and blocked issuing; it now reports valid when it unmounts, and no longer writes a ref during render. Claude-Session: https://claude.ai/code/session_01PZypiWDfMkDTeEPeXjRhW5
This commit is contained in:
@@ -39,8 +39,15 @@ export default function QuantityInput({ id, value, unit, onChange, disabled, onV
|
||||
const parsed = parseQuantity(text, unit);
|
||||
const clock = knownUnit(unit)?.clock;
|
||||
const validity = useRef(onValidity);
|
||||
validity.current = onValidity;
|
||||
useEffect(() => validity.current?.(parsed.ok), [parsed.ok]);
|
||||
useEffect(() => {
|
||||
validity.current = onValidity;
|
||||
});
|
||||
// Reported while this box exists; a box that goes away (its line was removed) stops counting as invalid.
|
||||
useEffect(() => {
|
||||
const report = validity.current;
|
||||
report?.(parsed.ok);
|
||||
return () => report?.(true);
|
||||
}, [parsed.ok]);
|
||||
|
||||
const helper = parsed.ok && text.includes(":") ? `= ${formatQuantity(parsed.value, "unit")} ${knownUnit(unit)?.short ?? ""}`.trim() : undefined;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user