Skip to content

Commit 9a2dba7

Browse files
committed
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`: https://github.com/facebook/react/blob/5cbe6258bc436b1683080a6d978c27849f1d9a22/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 #26596 (comment) and #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> DiffTrain build for commit 1f248bd.
1 parent 5b6046d commit 9a2dba7

File tree

13 files changed

+19
-19
lines changed

13 files changed

+19
-19
lines changed

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23745,7 +23745,7 @@ function createFiberRoot(
2374523745
return root;
2374623746
}
2374723747

23748-
var ReactVersion = "18.3.0-next-b90e8ebaa-20230419";
23748+
var ReactVersion = "18.3.0-next-1f248bdd7-20230419";
2374923749

2375023750
// Might add PROFILE later.
2375123751

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-prod.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8587,7 +8587,7 @@ var devToolsConfig$jscomp$inline_1023 = {
85878587
throw Error("TestRenderer does not support findFiberByHostInstance()");
85888588
},
85898589
bundleType: 0,
8590-
version: "18.3.0-next-b90e8ebaa-20230419",
8590+
version: "18.3.0-next-1f248bdd7-20230419",
85918591
rendererPackageName: "react-test-renderer"
85928592
};
85938593
var internals$jscomp$inline_1206 = {
@@ -8618,7 +8618,7 @@ var internals$jscomp$inline_1206 = {
86188618
scheduleRoot: null,
86198619
setRefreshHandler: null,
86208620
getCurrentFiber: null,
8621-
reconcilerVersion: "18.3.0-next-b90e8ebaa-20230419"
8621+
reconcilerVersion: "18.3.0-next-1f248bdd7-20230419"
86228622
};
86238623
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
86248624
var hook$jscomp$inline_1207 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react-test-renderer/cjs/ReactTestRenderer-profiling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9013,7 +9013,7 @@ var devToolsConfig$jscomp$inline_1065 = {
90139013
throw Error("TestRenderer does not support findFiberByHostInstance()");
90149014
},
90159015
bundleType: 0,
9016-
version: "18.3.0-next-b90e8ebaa-20230419",
9016+
version: "18.3.0-next-1f248bdd7-20230419",
90179017
rendererPackageName: "react-test-renderer"
90189018
};
90199019
var internals$jscomp$inline_1247 = {
@@ -9044,7 +9044,7 @@ var internals$jscomp$inline_1247 = {
90449044
scheduleRoot: null,
90459045
setRefreshHandler: null,
90469046
getCurrentFiber: null,
9047-
reconcilerVersion: "18.3.0-next-b90e8ebaa-20230419"
9047+
reconcilerVersion: "18.3.0-next-1f248bdd7-20230419"
90489048
};
90499049
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
90509050
var hook$jscomp$inline_1248 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if (
2727
}
2828
"use strict";
2929

30-
var ReactVersion = "18.3.0-next-b90e8ebaa-20230419";
30+
var ReactVersion = "18.3.0-next-1f248bdd7-20230419";
3131

3232
// ATTENTION
3333
// When adding new symbols to this file,

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-prod.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,4 +639,4 @@ exports.useSyncExternalStore = function (
639639
);
640640
};
641641
exports.useTransition = useTransition;
642-
exports.version = "18.3.0-next-b90e8ebaa-20230419";
642+
exports.version = "18.3.0-next-1f248bdd7-20230419";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/cjs/React-profiling.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ exports.useSyncExternalStore = function (
642642
);
643643
};
644644
exports.useTransition = useTransition;
645-
exports.version = "18.3.0-next-b90e8ebaa-20230419";
645+
exports.version = "18.3.0-next-1f248bdd7-20230419";
646646

647647
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
648648
if (
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b90e8ebaa5b692bcee4198eacb56f9123b62dd10
1+
1f248bdd7199979b050e4040ceecfe72dd977fd1

compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27052,7 +27052,7 @@ function createFiberRoot(
2705227052
return root;
2705327053
}
2705427054

27055-
var ReactVersion = "18.3.0-next-b90e8ebaa-20230419";
27055+
var ReactVersion = "18.3.0-next-1f248bdd7-20230419";
2705627056

2705727057
function createPortal$1(
2705827058
children,

compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9456,7 +9456,7 @@ var roots = new Map(),
94569456
devToolsConfig$jscomp$inline_1047 = {
94579457
findFiberByHostInstance: getInstanceFromNode,
94589458
bundleType: 0,
9459-
version: "18.3.0-next-b90e8ebaa-20230419",
9459+
version: "18.3.0-next-1f248bdd7-20230419",
94609460
rendererPackageName: "react-native-renderer",
94619461
rendererConfig: {
94629462
getInspectorDataForViewTag: function () {
@@ -9498,7 +9498,7 @@ var internals$jscomp$inline_1276 = {
94989498
scheduleRoot: null,
94999499
setRefreshHandler: null,
95009500
getCurrentFiber: null,
9501-
reconcilerVersion: "18.3.0-next-b90e8ebaa-20230419"
9501+
reconcilerVersion: "18.3.0-next-1f248bdd7-20230419"
95029502
};
95039503
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
95049504
var hook$jscomp$inline_1277 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10165,7 +10165,7 @@ var roots = new Map(),
1016510165
devToolsConfig$jscomp$inline_1125 = {
1016610166
findFiberByHostInstance: getInstanceFromNode,
1016710167
bundleType: 0,
10168-
version: "18.3.0-next-b90e8ebaa-20230419",
10168+
version: "18.3.0-next-1f248bdd7-20230419",
1016910169
rendererPackageName: "react-native-renderer",
1017010170
rendererConfig: {
1017110171
getInspectorDataForViewTag: function () {
@@ -10220,7 +10220,7 @@ var roots = new Map(),
1022010220
scheduleRoot: null,
1022110221
setRefreshHandler: null,
1022210222
getCurrentFiber: null,
10223-
reconcilerVersion: "18.3.0-next-b90e8ebaa-20230419"
10223+
reconcilerVersion: "18.3.0-next-1f248bdd7-20230419"
1022410224
});
1022510225
exports.createPortal = function (children, containerTag) {
1022610226
return createPortal$1(

0 commit comments

Comments
 (0)