-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix #7187: Provide readable input value based on selected option labels #7188
Fix #7187: Provide readable input value based on selected option labels #7188
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Skipped Deployments
|
Thanks a lot for your contribution! But, PR does not seem to be linked to any issues. Please manually link to an issue or mention it in the description using #<issue_id>. |
…based on the selected option labels
e5785e9
to
b4d5de6
Compare
Thanks a lot for your contribution! But, PR does not seem to be linked to any issues. Please manually link to an issue or mention it in the description using #<issue_id>. |
Thanks a lot for your contribution! But, PR does not seem to be linked to any issues. Please manually link to an issue or mention it in the description using #<issue_id>. |
@iamkyrylo thank you I assigned to PrimeTek for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Removing line with JSON.stringify breaks this fix #6897 |
I'm not sure I understand the issue. This doesn’t break anything. The input value shouldn’t consist of serialized objects with all their attributes. Instead, the input value should be a simple string made up of the option labels, as this is what users see on the screen and select from the dropdown. |
@ivanpajon Please take a closer look at the changes in this PR, specifically this line. With these changes, based on your example, the input value will be a simple string like |
@iamkyrylo yes, you are right, I have don't check it, sorry. In my case I need to use a custom object as the value so I think now I should use useOptionAsValue prop. I have check it with useOptionAsValue prop and in this case input value is |
Oh, I see what you mean and understand the problem. It’s not related to the I was misled by the component types, which indicated that Anyway, I can make a fix and remove this check from the condition. |
With optionLabel it works but not as intended. Expected behavior would be to get |
This approach is technically incorrect. Exposing the entire value in the dom is not good for accessibility and security. You should keep in mind that the input value in the dom is for users, not developers. If you need to handle the option object, store it in the component's state rather than serializing/deserializing a JSON string from the dom. I’m not sure why the I’d like to get the core team's thoughts on this. @melloware @nitrogenous |
totally agree with @iamkyrylo JSON in a readable element is wrong and a code smell. |
I've submitted a follow-up fix - #7216 |
I also don't like the approach with serialization. |
@ivanpajon I'm going to point this out again so you don't confuse or mislead yourself or others — it's not recommended to serialize objects for the input value, regardless of which form implementation you're using (NextJS, Remix, native, etc.). Since Check NextJS documentation again, and you’ll find a convenient solution that suits your case. |
Fix #7187