Skip to content

Comments

fix(Radio): support uncontrolled mode by using defaultChecked when no value prop#303

Open
GziXnine wants to merge 2 commits intochicagopcdc:devfrom
GziXnine:fix/radio-uncontrolled-mode
Open

fix(Radio): support uncontrolled mode by using defaultChecked when no value prop#303
GziXnine wants to merge 2 commits intochicagopcdc:devfrom
GziXnine:fix/radio-uncontrolled-mode

Conversation

@GziXnine
Copy link

@GziXnine GziXnine commented Feb 7, 2026

Summary

The Radio component always set checked={value !== undefined && option.value === value}, which forced fully-controlled behavior even when no value prop was provided.

Problem

In uncontrolled mode (no value prop), all radio buttons were permanently unchecked because the checked attribute always evaluated to false, overriding native HTML radio selection behavior. Clicking a radio button had no visible effect.

Fix

Use conditional props:

  • When a value prop is provided: use checked for controlled mode
  • When no value prop is provided: use defaultChecked to allow native browser radio selection

Fixes #276

Testing

  • Fixes the failing 'updates on click (uncontrolled)' test in Radio.test.tsx
  • All 4 Radio tests now pass (previously 3/4)
  • All 73 tests across the suite pass (previously 71/73)

grugna and others added 2 commits November 11, 2025 13:12
… value prop

The Radio component always set checked={value !== undefined && option.value === value},
which forced fully-controlled behavior even when no value prop was provided. In
uncontrolled mode (no value prop), all radio buttons were permanently unchecked
because the checked attribute always evaluated to false, overriding native HTML
radio selection behavior.

Use conditional props: when a value prop is provided, use checked for controlled
mode; when no value prop is provided, use defaultChecked to allow native browser
radio selection to work correctly.

This fixes the failing 'updates on click (uncontrolled)' test.
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.

2 participants