Skip to content

Commit

Permalink
fix: select console error to not suggest to set readonly to true (#27740
Browse files Browse the repository at this point in the history
)

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)
  • Loading branch information
hoxyq committed Dec 1, 2023
1 parent bb600b3 commit c35082f
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 50 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b8be034f07e1abc59863742063f5baeff20e33fe
5dd35968bef791ccc5948c657fabf191a77fff3f
21 changes: 14 additions & 7 deletions compiled/facebook-www/ReactDOM-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2989,12 +2989,19 @@ if (__DEV__) {
props.value == null
)
) {
error(
"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`."
);
if (tagName === "select") {
error(
"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`."
);
} else {
error(
"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`."
);
}
}

if (
Expand Down Expand Up @@ -34884,7 +34891,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "18.3.0-www-classic-c4c3bba3";
var ReactVersion = "18.3.0-www-classic-4a10d189";

function createPortal$1(
children,
Expand Down
21 changes: 14 additions & 7 deletions compiled/facebook-www/ReactDOM-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -2613,12 +2613,19 @@ if (__DEV__) {
props.value == null
)
) {
error(
"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`."
);
if (tagName === "select") {
error(
"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`."
);
} else {
error(
"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`."
);
}
}

if (
Expand Down Expand Up @@ -34705,7 +34712,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "18.3.0-www-modern-422c0869";
var ReactVersion = "18.3.0-www-modern-152469ca";

function createPortal$1(
children,
Expand Down
21 changes: 14 additions & 7 deletions compiled/facebook-www/ReactDOMServer-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");

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

// This refers to a WWW module.
var warningWWW = require("warning");
Expand Down Expand Up @@ -579,12 +579,19 @@ if (__DEV__) {
props.value == null
)
) {
error(
"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`."
);
if (tagName === "select") {
error(
"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`."
);
} else {
error(
"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`."
);
}
}

if (
Expand Down
21 changes: 14 additions & 7 deletions compiled/facebook-www/ReactDOMServer-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");

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

// This refers to a WWW module.
var warningWWW = require("warning");
Expand Down Expand Up @@ -579,12 +579,19 @@ if (__DEV__) {
props.value == null
)
) {
error(
"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`."
);
if (tagName === "select") {
error(
"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`."
);
} else {
error(
"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`."
);
}
}

if (
Expand Down
19 changes: 13 additions & 6 deletions compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,12 +576,19 @@ if (__DEV__) {
props.value == null
)
) {
error(
"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`."
);
if (tagName === "select") {
error(
"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`."
);
} else {
error(
"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`."
);
}
}

if (
Expand Down
21 changes: 14 additions & 7 deletions compiled/facebook-www/ReactDOMTesting-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3126,12 +3126,19 @@ if (__DEV__) {
props.value == null
)
) {
error(
"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`."
);
if (tagName === "select") {
error(
"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`."
);
} else {
error(
"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`."
);
}
}

if (
Expand Down Expand Up @@ -35508,7 +35515,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "18.3.0-www-classic-046bb5e3";
var ReactVersion = "18.3.0-www-classic-953cbc49";

function createPortal$1(
children,
Expand Down
21 changes: 14 additions & 7 deletions compiled/facebook-www/ReactDOMTesting-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -2750,12 +2750,19 @@ if (__DEV__) {
props.value == null
)
) {
error(
"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`."
);
if (tagName === "select") {
error(
"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`."
);
} else {
error(
"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`."
);
}
}

if (
Expand Down Expand Up @@ -35329,7 +35336,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "18.3.0-www-modern-16e0053f";
var ReactVersion = "18.3.0-www-modern-efdf5fd9";

function createPortal$1(
children,
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/ReactSharedSubset-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,4 +489,4 @@ exports.useId = function () {
exports.useMemo = function (create, deps) {
return ReactCurrentDispatcher.current.useMemo(create, deps);
};
exports.version = "18.3.0-www-modern-1669562e";
exports.version = "18.3.0-www-modern-b404772b";
1 change: 1 addition & 0 deletions compiled/facebook-www/WARNINGS
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@
"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."
"You passed a second argument to root.render(...) but it only accepts one argument."
"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`."
"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`."
"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`."
"You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "
"\"%s\" is not a supported revealOrder on <SuspenseList />. Did you mean \"together\", \"forwards\" or \"backwards\"?"
Expand Down

0 comments on commit c35082f

Please sign in to comment.