Closed cmd-johnson closed 1 month ago
See https://github.com/radix-ui/primitives/pull/2484#issuecomment-2379643220. We'll need to revert to the closet
check.
I'm actually going to close this for now. Per https://github.com/radix-ui/primitives/issues/2530#issuecomment-2380105452 I'd like to introduce a more wholistic solution to cover all affected primitives, and I still need to do some manual testing for edge cases.
Tracking in https://github.com/radix-ui/primitives/issues/2530
Description
This PR adds a new
form
prop to the Select.Root primitive which serves the same purpose as theform
attribute on a normal HTML<select>
element. This allows us to use radix Select elements outside of a form's markup and still have its value included in that form's submissions.Apart from adding the
form
prop to theSelect.Root
primitive, this PR also changes howisFormControl
is determined. Instead of usingelement.closest('form')
, it now useselement.form
. This shouldn't have an impact to controls that are located inside a<form>
already, because theform
attribute is automatically set to the parent form element. For elements outside a form, this attribute is unset, so it should be functionally the same as the previous behavior, with the added benefit of supporting overriding the associated form using theform
attribute passed to the element.There's more details in my original feature request #2975.