Skip to content

fix(react): allow null controlled RadioGroup values#3863

Open
raashish1601 wants to merge 1 commit intotailwindlabs:mainfrom
raashish1601:fix/headlessui-3844-radio-group-null-value
Open

fix(react): allow null controlled RadioGroup values#3863
raashish1601 wants to merge 1 commit intotailwindlabs:mainfrom
raashish1601:fix/headlessui-3844-radio-group-null-value

Conversation

@raashish1601
Copy link
Copy Markdown

Summary

  • allow RadioGroup to accept null as the controlled empty value again without broadening onChange to nullable values
  • keep the controlled-empty path typed through useControllable so the selected value can stay null until an option is chosen
  • add a regression that proves the null -> string controlled flow updates without triggering the uncontrolled-to-controlled warning

Testing

  • npx prettier --check packages/@headlessui-react/src/hooks/use-controllable.ts packages/@headlessui-react/src/components/radio-group/radio-group.tsx packages/@headlessui-react/src/components/radio-group/radio-group.test.tsx
  • npx jest packages/@headlessui-react/src/components/radio-group/radio-group.test.tsx --config packages/@headlessui-react/jest.config.cjs --runInBand
  • npx tsc --pretty false --noEmit --jsx react-jsx --module esnext --moduleResolution node --target esnext --strict --esModuleInterop --skipLibCheck false ./.tmp-headlessui-3844-dist.tsx (run against the built @headlessui/react package with value={selected ?? null})
  • ../../scripts/build.sh --external:react --external:react-dom --external:use-sync-external-store from packages/@headlessui-react under Git Bash with the workspace node_modules/.bin on PATH

Closes #3844.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 27, 2026

@raashish1601 is attempting to deploy a commit to the Tailwind Labs Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RadioGroup can no longer be used as a controlled component when there is no initial value

1 participant