Bug: Controlled `radio` element doesn't update the `checked` property when the selected radio changes

This issue has been created since 2022-11-15.

React version: 16.14.0, 18.2.0

Steps To Reproduce

  1. Create group of radio input element in a controlled way using the checked prop
  2. Click on an unselected element
  3. The clicked/selected element is now selected for the user
  4. The checked prop is still on the original radio input element

Link to code example:
https://codesandbox.io/s/funny-rui-tphkuc?file=/src/App.js:188-191

The current behavior

For a group of type="radio", the checked prop stays on the initially selected radio button
If the selected radio button changes, the state update correctly visually but the checked isn't add as a property in the DOM of the now selected radio button (and the previous selected radio button still have the checked property)

The expected behavior

For a group of type="radio", when changing the selected radio button, the checked property should be removed from the previously selected radio button and be added to the new one

eps1lon wrote this answer on 2022-11-15

The checked property is updated correctly. What you're referring to is the checked attribute which is not supposed to change. For CSS selectors use the :checked pseudo-selector instead.

Duplicate of #24439

mickaelzhang wrote this answer on 2022-11-16

@eps1lon Thanks for the clarification!
Using defaultChecked instead seems to change the attribute, I suppose it is a bug then

More Details About Repo
Owner Name facebook
Repo Name react
Full Name facebook/react
Language JavaScript
Created Date 2013-05-24
Updated Date 2022-12-01
Star Count 198482
Watcher Count 6646
Fork Count 41196
Issue Count 1106

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
Does ABC support clock triggered flipflop? 0 2022-01-05 2022-11-04
Support automatic update when using a floating image tag to a static tag 2 2022-01-20 2022-11-01
How to deal with nonlinear operator 1 2021-03-12 2022-10-25
coefficients: small offsets could raise `Cannot compute accuracy' error unexpectedly 2 2021-02-25 2022-11-30
求助,ddcheck插件缺少plugins.nonebot_plugin_htmlrender 2 2022-05-24 2022-08-21
Support make check (the GNU conventions) 0 2022-08-15 2022-11-27
Automatic detection of encoding 1 2021-04-09 2022-11-17
[BUG] Thumbnail not created properly 11 2022-08-07 2022-11-19
Problem with OPENHTJ2K 1 2021-09-20 2022-08-16
Multitab ipywidget tool being flagged as 3rd party widget 4 2022-07-14 2022-08-10
Translation correction 0 2021-12-02 2022-08-15
pong-1 issue with love 11.3 1 2020-11-03 2022-10-22
Guidelines Size 4 2020-05-19 2021-12-22
please help little problem 0 2020-04-04 2022-09-09
Credit Card - "Name on card" field not validated on submission 1 2021-11-16 2022-10-11
System Error when running Ganache 2.5.4 on win32 0 2022-03-21 2022-11-28
[Regression] Driver: San Francisco [BLES00891] freezes after a short period of time driving from 0.0.23-14079 onwards 2 2022-09-11 2022-10-26
部分图片未加载 网页版1.3 -1小节开头部分 #bug# 1 2021-08-09 2022-11-16
Dependency Dashboard 0 2021-08-25 2022-10-30
复制粘贴时可以过滤样式,那用js添加内容时怎样配置过滤样式。 1 2021-09-12 2022-10-07
Skip drawing of tiny line features 3 2022-03-02 2022-10-22
[Question] Difference between vacuum.sc and shulkerboxes.sc 2 2021-05-08 2022-09-22
Missing OS X binaries in 0.3.4 Bugfix Release 0 2022-05-02 2022-10-10
Option `julia.runtimeCompletions` is ignored 0 2021-11-14 2022-10-16
improve IBPSA merge commit message 3 2021-05-20 2022-11-18
How use nuget pack push on Jenkins installed on Linux 2 2022-08-26 2022-10-01
FMUL.S instructions set underflow flag of fflags wrongly 0 2022-09-27 2022-11-23
Connection Refused in Jenkins pipeline only 1 2022-05-18 2022-11-10
Install worked but pwsh did not run 2 2022-01-10 2022-10-11
Enum weird sorting state from add() vs using UI 1 2021-12-24 2022-10-16
Amplify 1.26.2 - Compilation issue 11 2022-07-13 2022-09-14
API.graphql returns incorrect type for promise result 1 2022-02-02 2022-11-22
Service Migration Automation 1 2021-04-22 2022-11-13
Android Basics: create-dice-roller-app-with-button 1 2021-02-27 2022-11-28
[bug] ng-zorro integration failed 0 2022-11-18 2022-11-23
tauri dev Or tauri build Failed[bug] 2 2022-11-17 2022-11-23
[feat] refactor InvokeResponse as a Rust Result 0 2022-11-17 2022-11-23
[bug] Not works with js-ipfs #2564 1 2022-11-18 2022-11-23
Unable to preserve login data under Ubuntu 7 2022-11-19 2022-11-23
InstancePrincipalsAuthenticationDetailsProviderExample 6 2018-04-27 2022-10-27
Transition azure-security-keyvault-keys to New Codesnippet Tooling 0 2021-10-21 2022-10-08
Refresh without loosing state? 4 2021-01-14 2022-10-11
Possible UB in min_heap 2 2021-07-08 2022-11-02
Question regarding the dev setup 1 2022-06-30 2022-11-07
Review API configuration parameters to match the new standard in affected repositories 1 2021-12-20 2022-10-30
Editor: Switch to classic editor sometimes silently fails. 1 2020-04-24 2021-12-01
AMQP consumer should not consume more messages than fit in the input buffer 2 2021-12-08 2022-11-26
Create a spring-cloud-bindings BindingsPropertiesProcessor for Apache Geode 2 2020-12-09 2022-11-28
BiometricPrompt dont show in some devices flutter 4 2022-10-10 2022-11-15
Flutter hasSize error 2 2022-03-17 2022-10-01