[RadioGroup] Form reset restores the value from mount instead of the current defaultValue
Bug report
Current Behavior
When the form containing an uncontrolled RadioGroup is reset, the group goes back to the value it had on its first render. It ignores any later change to the defaultValue prop.
This is easy to hit with React 19 form actions. React resets <form action={fn}> automatically after every action finishes. The usual way to keep the submitted values is to update defaultValue / defaultChecked to them, which is what libraries like Conform do. That works for native inputs, but RadioGroup goes back to the value it was mounted with. After saving, the user sees their selection jump back to the old value. The hidden input goes back too, so submitting the form again sends the old value.
Both the reset handler and the hidden bubble input seem to use values captured on mount:
const initialValueRef = React.useRef(value);
React.useEffect(() => {
// ...
const reset = () => setValue(initialValueRef.current);
associatedForm.addEventListener('reset', reset);
// ...
}, [control, form, setValue]);const defaultCheckedRef = React.useRef(checked);
// ...
defaultChecked={defaultCheckedRef.current}Expected behavior
Resetting the form should restore the current defaultValue. That is how a native <input type="radio"> behaves: a form reset restores its current checked content attribute, and React keeps that attribute in sync when the defaultChecked prop changes.
Reproducible example
https://github.com/user-attachments/assets/8cdc4438-cad5-47f7-b76b-bfc093900121
import { RadioGroup } from 'radix-ui';
import { useActionState } from 'react';
const options = ['a', 'b', 'c'];
type Saved = { radix: string; native: string };
export default function App() {
const [saved, formAction, isPending] = useActionState(
async (_prev: Saved, formData: FormData): Promise<Saved> => {
await new Promise((resolve) => setTimeout(resolve, 300));
return {
radix: String(formData.get('radix')),
native: String(formData.get('native')),
};
},
{ radix: 'a', native: 'a' },
);
return (
<form action={formAction}>
<p>Radix RadioGroup (defaultValue = "{saved.radix}")</p>
<RadioGroup.Root name="radix" defaultValue={saved.radix} style={{ display: 'flex', gap: 16 }}>
{options.map((value) => (
<label key={value} style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
<RadioGroup.Item value={value} style={{ width: 16, height: 16, padding: 0, borderRadius: '50%', border: '1px solid' }}>
<RadioGroup.Indicator style={{ display: 'block', width: 8, height: 8, margin: 'auto', borderRadius: '50%', background: 'black' }} />
</RadioGroup.Item>
{value}
</label>
))}
</RadioGroup.Root>
<p>Native radio (defaultChecked = "{saved.native}")</p>
<div style={{ display: 'flex', gap: 16 }}>
{options.map((value) => (
<label key={value}>
<input type="radio" name="native" value={value} defaultChecked={saved.native === value} />
{value}
</label>
))}
</div>
<p>
<button type="submit" disabled={isPending}>Save</button>
</p>
<p>Saved: {JSON.stringify(saved)}</p>
</form>
);
}Steps:
- Select
bin both groups. - Click "Save".
- The action finishes and React resets the form.
defaultValue/defaultCheckedare nowbfor both groups.- Native radio: stays on
b✅ - Radix
RadioGroup: goes back toa❌ (even though its label showsdefaultValue = "b"). Its hidden<input type="radio">is back onatoo, so clicking "Save" again submitsa.
- Native radio: stays on
Suggested solution
Reset to the latest defaultValue instead of the value captured on mount, e.g. keep the latest defaultValue in a ref and read it in the reset handler. The bubble input's defaultChecked should follow the same default. Then the native input's state after a reset, and the submitted FormData, stays consistent with the visible state.
Current workaround: remount the group when the default changes.
<RadioGroup.Root key={defaultValue} defaultValue={defaultValue}>Additional context
- Form reset support was added in #3958 (fixing #3177).
- In the same PR,
Switch,SelectandSliderseem to follow the same pattern: the initial state is captured withuseRefon mount and restored on reset. I have only verifiedRadioGroup. - Related: https://github.com/edmundhung/conform/issues/681 (React 19 automatically resets forms after actions).
Your environment
| Software | Name(s) | Version |
|---|---|---|
| Radix Package(s) | radix-ui (@radix-ui/react-radio-group) |
1.6.7 (1.4.7) |
| React | n/a | 19.3.0 |
| Browser | Chrome | 154.0.8037.58 |
| Assistive tech | n/a | n/a |
| Node | n/a | 24.21.0 |
| npm/yarn/pnpm | pnpm | 12.6.0 |
| Operating System | macOS | 26.6.2 |
Source: radix-ui/primitives