Skip to content

Commit c35082f

Browse files
committed
fix: select console error to not suggest to set readonly to true (#27740)
fix #27657 added test in the `ReactDOMSELECT-test.js` to not allow regession to happen in future. After changes this is what the error message looks like https://github.com/facebook/react/assets/72331432/53dcbe2a-70d2-43d2-a52d-a4fc389fdfbf DiffTrain build for [5dd3596](5dd3596)
1 parent bb600b3 commit c35082f

10 files changed

+100
-50
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b8be034f07e1abc59863742063f5baeff20e33fe
1+
5dd35968bef791ccc5948c657fabf191a77fff3f

compiled/facebook-www/ReactDOM-dev.classic.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2989,12 +2989,19 @@ if (__DEV__) {
29892989
props.value == null
29902990
)
29912991
) {
2992-
error(
2993-
"You provided a `value` prop to a form field without an " +
2994-
"`onChange` handler. This will render a read-only field. If " +
2995-
"the field should be mutable use `defaultValue`. Otherwise, " +
2996-
"set either `onChange` or `readOnly`."
2997-
);
2992+
if (tagName === "select") {
2993+
error(
2994+
"You provided a `value` prop to a form field without an " +
2995+
"`onChange` handler. This will render a read-only field. If " +
2996+
"the field should be mutable use `defaultValue`. Otherwise, set `onChange`."
2997+
);
2998+
} else {
2999+
error(
3000+
"You provided a `value` prop to a form field without an " +
3001+
"`onChange` handler. This will render a read-only field. If " +
3002+
"the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`."
3003+
);
3004+
}
29983005
}
29993006

30003007
if (
@@ -34884,7 +34891,7 @@ if (__DEV__) {
3488434891
return root;
3488534892
}
3488634893

34887-
var ReactVersion = "18.3.0-www-classic-c4c3bba3";
34894+
var ReactVersion = "18.3.0-www-classic-4a10d189";
3488834895

3488934896
function createPortal$1(
3489034897
children,

compiled/facebook-www/ReactDOM-dev.modern.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2613,12 +2613,19 @@ if (__DEV__) {
26132613
props.value == null
26142614
)
26152615
) {
2616-
error(
2617-
"You provided a `value` prop to a form field without an " +
2618-
"`onChange` handler. This will render a read-only field. If " +
2619-
"the field should be mutable use `defaultValue`. Otherwise, " +
2620-
"set either `onChange` or `readOnly`."
2621-
);
2616+
if (tagName === "select") {
2617+
error(
2618+
"You provided a `value` prop to a form field without an " +
2619+
"`onChange` handler. This will render a read-only field. If " +
2620+
"the field should be mutable use `defaultValue`. Otherwise, set `onChange`."
2621+
);
2622+
} else {
2623+
error(
2624+
"You provided a `value` prop to a form field without an " +
2625+
"`onChange` handler. This will render a read-only field. If " +
2626+
"the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`."
2627+
);
2628+
}
26222629
}
26232630

26242631
if (
@@ -34705,7 +34712,7 @@ if (__DEV__) {
3470534712
return root;
3470634713
}
3470734714

34708-
var ReactVersion = "18.3.0-www-modern-422c0869";
34715+
var ReactVersion = "18.3.0-www-modern-152469ca";
3470934716

3471034717
function createPortal$1(
3471134718
children,

compiled/facebook-www/ReactDOMServer-dev.classic.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if (__DEV__) {
1919
var React = require("react");
2020
var ReactDOM = require("react-dom");
2121

22-
var ReactVersion = "18.3.0-www-classic-e27c8048";
22+
var ReactVersion = "18.3.0-www-classic-0699b388";
2323

2424
// This refers to a WWW module.
2525
var warningWWW = require("warning");
@@ -579,12 +579,19 @@ if (__DEV__) {
579579
props.value == null
580580
)
581581
) {
582-
error(
583-
"You provided a `value` prop to a form field without an " +
584-
"`onChange` handler. This will render a read-only field. If " +
585-
"the field should be mutable use `defaultValue`. Otherwise, " +
586-
"set either `onChange` or `readOnly`."
587-
);
582+
if (tagName === "select") {
583+
error(
584+
"You provided a `value` prop to a form field without an " +
585+
"`onChange` handler. This will render a read-only field. If " +
586+
"the field should be mutable use `defaultValue`. Otherwise, set `onChange`."
587+
);
588+
} else {
589+
error(
590+
"You provided a `value` prop to a form field without an " +
591+
"`onChange` handler. This will render a read-only field. If " +
592+
"the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`."
593+
);
594+
}
588595
}
589596

590597
if (

compiled/facebook-www/ReactDOMServer-dev.modern.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if (__DEV__) {
1919
var React = require("react");
2020
var ReactDOM = require("react-dom");
2121

22-
var ReactVersion = "18.3.0-www-modern-1669562e";
22+
var ReactVersion = "18.3.0-www-modern-b404772b";
2323

2424
// This refers to a WWW module.
2525
var warningWWW = require("warning");
@@ -579,12 +579,19 @@ if (__DEV__) {
579579
props.value == null
580580
)
581581
) {
582-
error(
583-
"You provided a `value` prop to a form field without an " +
584-
"`onChange` handler. This will render a read-only field. If " +
585-
"the field should be mutable use `defaultValue`. Otherwise, " +
586-
"set either `onChange` or `readOnly`."
587-
);
582+
if (tagName === "select") {
583+
error(
584+
"You provided a `value` prop to a form field without an " +
585+
"`onChange` handler. This will render a read-only field. If " +
586+
"the field should be mutable use `defaultValue`. Otherwise, set `onChange`."
587+
);
588+
} else {
589+
error(
590+
"You provided a `value` prop to a form field without an " +
591+
"`onChange` handler. This will render a read-only field. If " +
592+
"the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`."
593+
);
594+
}
588595
}
589596

590597
if (

compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -576,12 +576,19 @@ if (__DEV__) {
576576
props.value == null
577577
)
578578
) {
579-
error(
580-
"You provided a `value` prop to a form field without an " +
581-
"`onChange` handler. This will render a read-only field. If " +
582-
"the field should be mutable use `defaultValue`. Otherwise, " +
583-
"set either `onChange` or `readOnly`."
584-
);
579+
if (tagName === "select") {
580+
error(
581+
"You provided a `value` prop to a form field without an " +
582+
"`onChange` handler. This will render a read-only field. If " +
583+
"the field should be mutable use `defaultValue`. Otherwise, set `onChange`."
584+
);
585+
} else {
586+
error(
587+
"You provided a `value` prop to a form field without an " +
588+
"`onChange` handler. This will render a read-only field. If " +
589+
"the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`."
590+
);
591+
}
585592
}
586593

587594
if (

compiled/facebook-www/ReactDOMTesting-dev.classic.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3126,12 +3126,19 @@ if (__DEV__) {
31263126
props.value == null
31273127
)
31283128
) {
3129-
error(
3130-
"You provided a `value` prop to a form field without an " +
3131-
"`onChange` handler. This will render a read-only field. If " +
3132-
"the field should be mutable use `defaultValue`. Otherwise, " +
3133-
"set either `onChange` or `readOnly`."
3134-
);
3129+
if (tagName === "select") {
3130+
error(
3131+
"You provided a `value` prop to a form field without an " +
3132+
"`onChange` handler. This will render a read-only field. If " +
3133+
"the field should be mutable use `defaultValue`. Otherwise, set `onChange`."
3134+
);
3135+
} else {
3136+
error(
3137+
"You provided a `value` prop to a form field without an " +
3138+
"`onChange` handler. This will render a read-only field. If " +
3139+
"the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`."
3140+
);
3141+
}
31353142
}
31363143

31373144
if (
@@ -35508,7 +35515,7 @@ if (__DEV__) {
3550835515
return root;
3550935516
}
3551035517

35511-
var ReactVersion = "18.3.0-www-classic-046bb5e3";
35518+
var ReactVersion = "18.3.0-www-classic-953cbc49";
3551235519

3551335520
function createPortal$1(
3551435521
children,

compiled/facebook-www/ReactDOMTesting-dev.modern.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2750,12 +2750,19 @@ if (__DEV__) {
27502750
props.value == null
27512751
)
27522752
) {
2753-
error(
2754-
"You provided a `value` prop to a form field without an " +
2755-
"`onChange` handler. This will render a read-only field. If " +
2756-
"the field should be mutable use `defaultValue`. Otherwise, " +
2757-
"set either `onChange` or `readOnly`."
2758-
);
2753+
if (tagName === "select") {
2754+
error(
2755+
"You provided a `value` prop to a form field without an " +
2756+
"`onChange` handler. This will render a read-only field. If " +
2757+
"the field should be mutable use `defaultValue`. Otherwise, set `onChange`."
2758+
);
2759+
} else {
2760+
error(
2761+
"You provided a `value` prop to a form field without an " +
2762+
"`onChange` handler. This will render a read-only field. If " +
2763+
"the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`."
2764+
);
2765+
}
27592766
}
27602767

27612768
if (
@@ -35329,7 +35336,7 @@ if (__DEV__) {
3532935336
return root;
3533035337
}
3533135338

35332-
var ReactVersion = "18.3.0-www-modern-16e0053f";
35339+
var ReactVersion = "18.3.0-www-modern-efdf5fd9";
3533335340

3533435341
function createPortal$1(
3533535342
children,

compiled/facebook-www/ReactSharedSubset-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,4 +489,4 @@ exports.useId = function () {
489489
exports.useMemo = function (create, deps) {
490490
return ReactCurrentDispatcher.current.useMemo(create, deps);
491491
};
492-
exports.version = "18.3.0-www-modern-1669562e";
492+
exports.version = "18.3.0-www-modern-b404772b";

compiled/facebook-www/WARNINGS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@
345345
"You passed a container to the second argument of root.render(...). You don't need to pass it again since you already passed it to create the root."
346346
"You passed a second argument to root.render(...) but it only accepts one argument."
347347
"You provided a `checked` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultChecked`. Otherwise, set either `onChange` or `readOnly`."
348+
"You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set `onChange`."
348349
"You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`."
349350
"You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "
350351
"\"%s\" is not a supported revealOrder on <SuspenseList />. Did you mean \"together\", \"forwards\" or \"backwards\"?"

0 commit comments

Comments
 (0)