react / react/react

Bug: input[type="radio"] controlled value can get out-of-sync

Open
#19,860 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Component: DOM Status: Unconfirmed Type: Bug
Dominant language
JavaScript
Stars
251k
Forks
51.4k
Avg merge
2d 4h
Merged PRs (30d)
53

Description

React version: 16.13.1 and 17.0.0-alpha.0-2d131d782

Steps To Reproduce

  1. Render two input[type="radio"][name="radio"]: one is checked, one isn't
  2. Get warning about passing onChange or readOnly
  3. Add empty onChange to both

Link to code example:

The current behavior

screencapture of the described behavior

  1. React recommends readOnly for input[type="radio"] even though this isn't supported natively (though React could polyfill it)
  2. After looping through the radios once with arrow key navigation the checked state changes

The expected behavior

Arrow key navigation shouldn't break out of the controlled value. It's debateable whether React should recommend readOnly when this isn't a standard attribute like readOnly for <input type="text" />.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named in the report. Begin with the linked React 16, 17, and 18 CodeSandbox reproductions, then trace the radio input handling that produces the controlled-state mismatch. Done means arrow-key navigation no longer changes the controlled checked value; the readOnly warning question remains part of the issue's discussion.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.