🐛 fix(forms): Add step attribute to number inputs for better value control

This commit is contained in:
web@ppanel
2025-03-17 22:47:42 +07:00
parent aa1d42651d
commit b8f4f1e694
4 changed files with 20 additions and 5 deletions
@@ -33,8 +33,16 @@ export function ObjectInput<T extends Record<string, any>>({
const [internalState, setInternalState] = useState<T>(value);
useEffect(() => {
setInternalState(value);
}, [value]);
let updatedState = { ...internalState, ...value };
fields.forEach((field) => {
if (field.calculateValue) {
updatedState = field.calculateValue(updatedState);
}
});
setInternalState(updatedState);
}, [value, fields]);
const updateField = (key: keyof T, fieldValue: string | number | boolean) => {
let updatedInternalState = { ...internalState, [key]: fieldValue };