-
Notifications
You must be signed in to change notification settings - Fork 47k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Select when passed a value as Prop errors with a suggestion to pass readOnly #27657
Comments
I can work on this and make the error message correctly prompt. |
Does this work in your case? |
@felipe-rodolfo the bug is not related to how i should use the Select component, the error message is the Problem since it says to pass a readOnly value to pass a prop as the option for the Select component which does not has the same and does not seem to be a good developer experience. |
cc @hoxyq do lmk if this something valuable to fix!! |
I think it is worth fixing, especially given the fact that https://react.dev/reference/react-dom/components/select doesn't list
I am not familiar with the code where this happens, but maybe its worth just implementing its own validation for |
ok will look up we have holidays here till next week. |
@hoxyq can you change the status to confirmed if possible? |
@hoxyq could you spare a few minutes to run the if you are able to see |
Can confirm that it doesn't work for me also. Looks like a recent regression, but I don't have the time now to bisect the PR, which introduced this. I've validated that sourcemaps PRs are not related to it, so there is some commit prior to it that breaks this. |
ok @hoxyq i understand appreciate your investigation, any other way i can test my changes if you know, i tried copying the node modules from the |
Jest tests, probably? Or try checking out on some older commit. I've tried |
Thanks for the follow up, will try doing the same |
Should be fixed with #27717. |
thanks @hoxyq , i have also found the file to change and return the appropriate error, once this is merged, i will take a pull and test the changes locally and add appropriate tests. |
) 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
) 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)
Just ran into this and was very confused.
To back this up, the TypeScript definitions also do not accept Here's the thing about just changing the error message though... I'm using Zag.js for a single/multi-select component, and I have the following code to render a hidden input, which exists solely to provide a value to <select
{...api.hiddenSelectProps}
value={multi ? api.value : api.value[0]}
>
{options.map((option, index) => (
<option key={index} value={option.id}>
{option.text}
</option>
))}
</select> Zag already tracks the state via a statemachine, and the user is able to control the input via other controls that I didn't show. Therefore I really need a So as far as I can see, to make the error go away, I have to provide |
IMHO, setting |
…ebook#27740) fix facebook#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
) 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 commit 5dd3596.
Seems weird when we try to use a
select
component, and pass a value as a prop, it prompts with the error to either setonChange
orreadOnly
.the
readOnly
at the last seems misleading since theselect
component does not have areadOnly
prop, unlike inputs which do have areadOnly
attribute.SELECT PROPS
https://react.dev/reference/react-dom/components/select
seems an easy fix would be to check if the mounted component is a
select
component and then conditionally just change the error message, though would need to add tests to support the same.Screen.Recording.2023-11-06.at.9.27.49.AM.mov
cc @sophiebits
codesandbox link to tinker:- https://codesandbox.io/s/admiring-wright-9sctsn?file=/src/App.js
The text was updated successfully, but these errors were encountered: