Skip to content
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 isFormControl to check if form attribute is defined (checkbox, radio-group, select, slider, switch) #2668

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

seanlennaerts
Copy link

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

@seanlennaerts seanlennaerts changed the title Fix isFormControl check to include presence of form attribute (checkbox, radio-group, select, slider, switch) Fix isFormControl to check if form attribute is defined (checkbox, radio-group, select, slider, switch) Jan 26, 2024
@seanlennaerts
Copy link
Author

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.

@nicolastoulemont
Copy link

nicolastoulemont commented Mar 18, 2024

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

@DarkPurple141
Copy link

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 🙏

@evadecker
Copy link

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.

@chaance
Copy link
Member

chaance commented Sep 27, 2024

Tracking in #2530. I still need to do some manual testing for edge cases, but I'm planning to address this soon. Thanks for your patience!

@chaance chaance added Resolution: Needs Investigation This issue needs more investigation Priority: High High priority issue labels Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: High High priority issue Resolution: Needs Investigation This issue needs more investigation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Checkbox and other components do not render <input> element with form attribute
5 participants