diff --git a/components/forms/SettingsSubmit.tsx b/components/forms/SettingsSubmit.tsx index f0f949a4..99a9ffe1 100644 --- a/components/forms/SettingsSubmit.tsx +++ b/components/forms/SettingsSubmit.tsx @@ -490,6 +490,8 @@ export default function SettingsSubmit(props: CreateProps | EditProps) { handleSubmit, control, reset, + setValue, // ← added + getValues, // ← added formState: { isSubmitting }, } = useForm({ defaultValues: { @@ -541,6 +543,30 @@ export default function SettingsSubmit(props: CreateProps | EditProps) { } }, [isEdit, edit?.initialValues, reset]); + // After reset, force RHF values for selects so the browser matches options when they hydrate + useEffect(() => { + if (!isEdit || !current) return; + + const fieldNames = [ + "laser_soft", + "mat", + "mat_coat", + "mat_color", + "mat_opacity", + "source", + "lens", + ] as const; + + const values = getValues(); + fieldNames.forEach((name) => { + const cur = (current as any)[name]; + const now = (values as any)[name]; + if (cur && (now == null || now === "")) { + setValue(name as any, cur, { shouldDirty: false, shouldValidate: false }); + } + }); + }, [isEdit, current, getValues, setValue]); + function num(v: any) { return v === "" || v == null ? null : Number(v); }