-
Notifications
You must be signed in to change notification settings - Fork 981
[Select] Add required prop #1598
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
Conversation
<Select.Portal> | ||
<Select.Content className={contentClass()}> | ||
<Select.Viewport className={viewportClass()}> | ||
<Select.Item className={itemClass()} value=""> |
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.
Not sure if it's a bug, but I have to add this item with value=""
, because when I tried with just defaultValue
as undefined, it selects the first item when submitting the form.
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.
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.
I believe this was fixed already a while ago, could you try removing and double-checking?
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.
Did you manage to double-check this?
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.
Hi, sorry I missed this comment. I will do it later after workhours.
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.
Update on this @benoitgrelard. This is still happening
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.
Yeah that makes sense because the native select underneath has a value by default even when no default value is given: https://codesandbox.io/s/native-select-required-7kb1g0?file=/src/App.js
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.
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.
Oh I see, it's potentially an issue that it doesn't match because it prevents required
to work.
For example if someone doesn't provide a defaultValue
or value
and uses placeholder
on Value
, it looks like the Select
is waiting for the user to pick a value and therefore should stop form submitting if required
, yet it wouldn't.
Maybe if a placeholder
is provided, we automatically insert a "" option in the native select.
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.
Follow-up: #1711
Hey @norman-ags, Would you be able to push a change, or force-push to re-trigger the CI checks. Not sure why they didn't run. Thanks 🙏 |
Hello @norman-ags, I'd like to recreate your PR if you don't mind since I need this too |
bb2019f
to
b9267cd
Compare
Hi guys. Sorry was on vacation.
@benoitgrelard done. |
@norman-ags Could you re-run the version check and add the top-level project as "decline"? Thanks! |
@norman-ags could you rebase your branch? |
e9ae74f
to
e12580c
Compare
Done, I'll check the bug issue I noticed last time later. Thanks |
* Initial * Align release notes with latest changes (#468) * Update release notes * Create new toast page * Document onResume, onPause toast props * Document latest changes (#470) * Document latest changes * Update data/primitives/overview/releases.mdx Co-authored-by: Andy Hook <[email protected]> Co-authored-by: Andy Hook <[email protected]> * Add note regarding toast timer fix (#474) * Document latest Label changes (#475) * Document latest Label changes * Update copy * Apply suggestions from code review Co-authored-by: Andy Hook <[email protected]> Co-authored-by: Andy Hook <[email protected]> * Document 1693 changes (#478) radix-ui/primitives#1693 * Latest slider updates (#480) * Latest slider updates radix-ui/primitives#1695 * Update data/primitives/overview/releases.mdx Co-authored-by: Andy Hook <[email protected]> Co-authored-by: Andy Hook <[email protected]> * Add missing inverted prop to Slider (#482) * Document latest changes (#481) * Add selection improvement release note (#483) * Document Radio Group `disabled` prop (#484) * Create radio group file * Add note and prop docs addition * Add data-disabled attribute * Document latest slider changes (#489) * Document latest slider changes radix-ui/primitives#1696 * Update data/primitives/components/slider/1.1.0.mdx Co-authored-by: Andy Hook <[email protected]> Co-authored-by: Andy Hook <[email protected]> * [Select] Add `disabled` to API Reference (#488) * [Select] Create docs file * [Select] Add note and props addition * Document latest Select changes (#490) radix-ui/primitives#1598 * Update release note (#491) * Latest Slots updates (#492) * Latest Slots updates radix-ui/primitives#1713 * Fix typo * Document latest `DropdownMenu`/`ContextMenu` changes (`CheckboxItem` indeterminate) (#493) * Changelog * Duplicate files * Docs changes * PR feedback * Document `NavigationMenu` delay props (#495) * Add version page * Documentation changes * Update release filenames and breaking demo changes (#497) * Tweak release note, add date * Rename patch pages * Rename remaining patched packages * Bump files / versions * Fix build Co-authored-by: Benoît Grélard <[email protected]> Co-authored-by: Faqih Muntashir <[email protected]>
Description
Addresses: #1592