Mobile Bug Fixes
This commit is contained in:
@@ -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];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user