primitives
primitives copied to clipboard
Fix isFormControl to check if form attribute is defined (checkbox, radio-group, select, slider, switch)
Description
In some situations it is useful to render form inputs outside of a form. Inputs have a form
attribute where you can specify which form the input is associated with. This PR fixes the isFormControl
check to not only check if the input is contained in a form but to also check if the form attribute has been specified. It also passes the form attribute to the hidden input so that it will be submitted correctly.
Fixes #2530
Hey @benoitgrelard / @andy-hook any updates here? Let me know what I can do to get this PR over the line. If there are plans to merge this then I can fix the conflicts.
Facing the same issue in my remix apps. Indeed, Remix heavily encourages uncontrolled components and form-based mutation/query, and using form IDs is a quite common way to solve the layout challenges that complex UI raises.
So far, this lack of support for the form prop and the way the isFormControl is resolved is preventing me from using these components in anything other than basic forms.
Happy to do whatever is needed to help this PR get merged & released
Hi folks thought I'd chime in on this one as this would be a welcome change - let us know if more discussion desired to make this work or help wanted 🙏
This problem is currently biting me too. I'm using Remix and React Testing Library, and currently even though I've defined name
props for my Select
component, they aren't showing up in tests because no native component is being rendered.