react/packages
Sebastian Markbåge 1f248bdd71
Switching checked to null should leave the current value (#26667)
I accidentally made a behavior change in the refactor. It turns out that
when switching off `checked` to an uncontrolled component, we used to
revert to the concept of "initialChecked" which used to be stored on
state.

When there's a diff to this computed prop and the value of props.checked
is null, then we end up in a case where it sets `checked` to
`initialChecked`:


5cbe6258bc/packages/react-dom-bindings/src/client/ReactDOMInput.js (L69)

Since we never changed `initialChecked` and it's not relevant if
non-null `checked` changes value, the only way this "change" could
trigger was if we move from having `checked` to having null.

This wasn't really consistent with how `value` works, where we instead
leave the current value in place regardless. So this is a "bug fix" that
changes `checked` to be consistent with `value` and just leave the
current value in place. This case should already have a warning in it
regardless since it's going from controlled to uncontrolled.

Related to that, there was also another issue observed in
https://github.com/facebook/react/pull/26596#discussion_r1162295872 and
https://github.com/facebook/react/pull/26588

We need to atomically apply mutations on radio buttons. I fixed this by
setting the name to empty before doing mutations to value/checked/type
in updateInput, and then set the name to whatever it should be. Setting
the name is what ends up atomically applying the changes.

---------

Co-authored-by: Sophie Alpert <git@sophiebits.com>
2023-04-19 11:46:29 -04:00
..
dom-event-testing-library Avoid meta programming to initialize functions in module scope (#26388) 2023-03-14 21:00:22 -04:00
eslint-plugin-react-hooks Upgrade prettier (#26081) 2023-01-31 08:25:05 -05:00
internal-test-utils [Tests] `waitForThrow` should diff strings (#26568) 2023-04-07 14:14:08 -07:00
jest-react Move internalAct to internal-test-utils package (#26344) 2023-03-08 12:58:31 -05:00
react Delete unused `eventTimes` Fiber field (#26599) 2023-04-11 08:23:04 -04:00
react-art Synchronously flush the transition lane scheduled in a popstate event (#26025) 2023-04-13 15:21:19 -04:00
react-cache Convert more Suspense tests to use act (2/n) (#26610) 2023-04-12 13:36:13 -04:00
react-client [Flight] Serialize Date (#26622) 2023-04-18 20:52:03 -07:00
react-debug-tools [flow] make Flow suppressions explicit on the error (#26487) 2023-03-27 13:43:04 +02:00
react-devtools React DevTools 4.27.4 -> 4.27.5 (#26637) 2023-04-17 17:42:02 +01:00
react-devtools-core React DevTools 4.27.4 -> 4.27.5 (#26637) 2023-04-17 17:42:02 +01:00
react-devtools-extensions chore[devtools/release-scripts]: update messages / fixed npm view com… (#26660) 2023-04-19 10:05:16 +01:00
react-devtools-inline React DevTools 4.27.4 -> 4.27.5 (#26637) 2023-04-17 17:42:02 +01:00
react-devtools-shared cleanup[devtools]: remove named hooks & profiler changed hook indices feature flags (#26635) 2023-04-19 10:05:31 +01:00
react-devtools-shell refactor[devtools]: forbid editing class instances in props (#26522) 2023-04-03 11:32:17 +01:00
react-devtools-timeline React DevTools 4.27.4 -> 4.27.5 (#26637) 2023-04-17 17:42:02 +01:00
react-dom Switching checked to null should leave the current value (#26667) 2023-04-19 11:46:29 -04:00
react-dom-bindings Switching checked to null should leave the current value (#26667) 2023-04-19 11:46:29 -04:00
react-interactions [flow] make Flow suppressions explicit on the error (#26487) 2023-03-27 13:43:04 +02:00
react-is [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
react-native-renderer Synchronously flush the transition lane scheduled in a popstate event (#26025) 2023-04-13 15:21:19 -04:00
react-noop-renderer Synchronously flush the transition lane scheduled in a popstate event (#26025) 2023-04-13 15:21:19 -04:00
react-reconciler Synchronously flush the transition lane scheduled in a popstate event (#26025) 2023-04-13 15:21:19 -04:00
react-refresh Rename HostConfig files to FiberConfig to clarify they are configs fo… (#26592) 2023-04-10 14:58:44 -07:00
react-server [Flight] Serialize Date (#26622) 2023-04-18 20:52:03 -07:00
react-server-dom-relay Rename ReactServerFormatConfig to ReactFizzConfig (#26591) 2023-04-10 14:54:26 -07:00
react-server-dom-webpack [Flight] Serialize Date (#26622) 2023-04-18 20:52:03 -07:00
react-server-native-relay Normalize ReactFlightServerConfig and related files (#26589) 2023-04-10 14:47:23 -07:00
react-suspense-test-utils [Codemod] Update copyright header to Meta (#25315) 2022-10-18 11:19:24 -04:00
react-test-renderer Synchronously flush the transition lane scheduled in a popstate event (#26025) 2023-04-13 15:21:19 -04:00
scheduler Internal test helpers: Use Node's MessageChannel to queue task (#26345) 2023-03-08 15:04:38 -05:00
shared Remove revertRemovalOfSiblingPrerendering killswitch (#26549) 2023-04-12 21:05:17 -04:00
use-subscription Revert "Cleanup enableSyncDefaultUpdate flag (#26236)" (#26528) 2023-04-04 10:08:14 -04:00
use-sync-external-store Codemod redundant async act scopes (#26350) 2023-03-08 16:40:23 -05:00