Skip to content

fix(react): allow nullable controlled RadioGroup values#3864

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

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

Conversation

@raashish1601
Copy link
Copy Markdown

@raashish1601 raashish1601 commented Mar 27, 2026

Fixes #3844.

Summary

  • allow RadioGroup to accept null as the controlled empty-state value without widening the option type emitted by onChange
  • extend useControllable so components can store a broader controlled value type than the narrower value type they emit
  • add a compile-only regression fixture for value={selected ?? null} with onChange={setSelected}

Testing

  • npx tsc -p packages/@headlessui-react/tsconfig.json --noEmit
  • npx jest packages/@headlessui-react/src/components/radio-group/radio-group.test.tsx --runInBand
  • npx prettier --check packages/@headlessui-react/src/components/radio-group/radio-group.tsx packages/@headlessui-react/src/hooks/use-controllable.ts packages/@headlessui-react/types/radio-group.test.tsx

@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