Mobile Bug Fixes

This commit is contained in:
Eric gullickson
2025-09-22 20:31:27 -05:00
parent 3588372cef
commit 0f39e5eb7f
7 changed files with 86 additions and 495 deletions

View File

@@ -1,4 +1,4 @@
import React, { useEffect, useMemo, useState } from 'react';
import React, { useEffect, useMemo, useState, useRef } from 'react';
import { useForm, Controller } from 'react-hook-form';
import { z } from 'zod';
import { zodResolver } from '@hookform/resolvers/zod';
@@ -34,6 +34,7 @@ export const FuelLogForm: React.FC<{ onSuccess?: () => void; initial?: Partial<C
const { userSettings } = useUserSettings();
const { createFuelLog, isLoading } = useFuelLogs();
const [useOdometer, setUseOdometer] = useState(false);
const formInitialized = useRef(false);
const { control, handleSubmit, watch, setValue, formState: { errors, isValid } } = useForm<CreateFuelLogRequest>({
resolver: zodResolver(schema),
@@ -45,6 +46,13 @@ export const FuelLogForm: React.FC<{ onSuccess?: () => void; initial?: Partial<C
} as any
});
// Prevent form reset after initial load
useEffect(() => {
if (!formInitialized.current) {
formInitialized.current = true;
}
}, []);
const watched = watch(['fuelUnits', 'costPerUnit']);
const [fuelUnitsRaw, costPerUnitRaw] = watched as [string | number | undefined, string | number | undefined];