fix: phone provider (#44974)

fixes phone provider saves that showed success but did not persist the
enabled state
(smol regression from the refactor)


## ref:
- closes https://github.com/supabase/supabase/issues/44966

ig was introduced by 6b35cc8034


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Automatically clears certain conditional fields when their visibility
condition becomes false to avoid stale values.
* Preserves input values and registration state for fields removed from
the UI (they no longer unregister on hide), improving form continuity
during toggles.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Vaibhav authored and GitHub committed 2026-04-17 07:22:24 -06:00
1 parent 9c155a2192
commit bd04a59dec
2 files changed
+11 -3

No files matched your search

@@ -1,6 +1,7 @@
import { format } from 'date-fns'
import { CalendarIcon, ExternalLink } from 'lucide-react'
import { type Control } from 'react-hook-form'
import { useEffect } from 'react'
import { useFormContext, type Control } from 'react-hook-form'
import ReactMarkdown from 'react-markdown'
import {
Button,
@@ -53,6 +54,7 @@ const FormField = ({
disabled: disabledProp,
readOnly,
}: FormFieldProps) => {
const { setValue } = useFormContext()
const { description: originalDescription } = properties
let description = originalDescription
@@ -79,6 +81,12 @@ const FormField = ({
disabled: properties.show == null,
})
useEffect(() => {
if (properties.show?.key != null && !showValue && fieldValue !== '') {
setValue(name, '', { shouldDirty: true })
}
}, [fieldValue, name, properties.show?.key, setValue, showValue])
if (properties.show) {
if (properties.show.matches) {
if (!properties.show.matches.includes(showValue)) {
@@ -341,7 +349,7 @@ const FormField = ({
>
<FormControl_Shadcn_ className="col-span-6">
<Select_Shadcn_
defaultValue={properties.enum[0]}
defaultValue={properties.enum[0]?.value}
value={field.value}
onValueChange={field.onChange}
>
@@ -165,7 +165,7 @@ export const ProviderForm = ({ config, provider, isActive }: ProviderFormProps)
const form = useForm({
defaultValues: INITIAL_VALUES,
resolver: zodResolver(provider.validationSchema),
shouldUnregister: true,
shouldUnregister: false,
})
useEffect(() => {