-
Notifications
You must be signed in to change notification settings - Fork 908
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
Hook components that should go into forms into Form Submission #289
Comments
fwiw, an approach I've used is to wrap from elements in custom components and the webcomponent updates the value of the wrapped element. It could inject a hidden input into the wrapped light dom as a polyfill, or use one if it's already there to give the user more control. |
What would be the downside of not using shadowDom for form-y components? Maybe you can use other css encapsulation technique that exposes the inner input to the light dom, because as they are right now, sadly it is very cumbersome to use this components in a form. This is the approach Ionic uses for their components, for example. |
The downside is that element internals are unsafely exposed to external CSS styles. The purpose of shadow DOM is to provide protection and ensure that the elements are not affects by any external styles. Luckily there are some great solutions for custom elements and forms as mentioned in this issue! The next step is implementing them. While you wait for support to be built-in, you can always hook up the components today using FormData events. Here's a great blog post with instructions on how to do that: https://web.dev/more-capable-form-controls/#event-based-api |
Thanks for the explanation. In the meantime, I am copying the value on changes to a hidden input so the form can access it. I hope we can all use FormData events soon but it seems that right now they are not supported by Safari and no easy polyfill is possible (https://caniuse.com/#search=formdata%20event). Great work you are doing over here. Thanks a lot! |
If the choice is to implement Form Associated Custom Elements there's a polyfill that might be worth investigating |
@dfreedm |
@asyncLiz and the team: since this discussion kind of ended with no concrete decisions, I'd be happy to hear your take on the subject. Having played with all those myself, on top of your components of course, I must admit that probably the cheapest solution is to take the native Any chance, that you may consider a component flavor where you allow custom slotted input to opt in, while having your own default one? |
Looking at the web components polyfills repo seems like there's no progress either: Does this mean that the standards Form Associated Custom Elements and FormData event are not going to go through? |
No, it does not. It only means there are currently other high priority items the team is working on, such as completing our catalog of components, full theming capabilities, ARIA support, and RTL support. We know that native form submission is a highly anticipated feature, but please be patient while all the features for the project are prioritized! When there's an update or progress being made we'll post in this thread. |
Thank you for the update @asyncLiz, I'm also looking for the other priorities you mentioned. Exciting times! |
Saw the element-internals-polyfill mentioned above and figured I'd drop in. That polyfill is mostly feature complete at this point except for
I'm also dropping a comment to follow this thread to see where material lands on this issue. |
Hello. Any updates on a timeline for this? |
- Relies on `FormDataEvent`, which is supported by Chrome, Firefox, and Edge. - Safari and IE will need a polyfill - Require `name`, `value`, and `disabled` properties on FormElement subclasses - Add `formDataCallback()` function to control what is added to the Form submission - Set `checkbox`, `radio`, and `switch` `value` property to `on` by default, to match native controls Fixes #289 PiperOrigin-RevId: 381974666
- Relies on `FormDataEvent`, which is supported by Chrome, Firefox, and Edge. - Safari and IE will need a polyfill - Require `name`, `value`, and `disabled` properties on FormElement subclasses - Add `formDataCallback()` function to control what is added to the Form submission - Set `checkbox`, `radio`, and `switch` `value` property to `on` by default, to match native controls Fixes #289 PiperOrigin-RevId: 381974666
- Relies on `FormDataEvent`, which is supported by Chrome, Firefox, and Edge. - Safari and IE will need a polyfill - Require `name`, `value`, and `disabled` properties on FormElement subclasses - Add `formDataCallback()` function to control what is added to the Form submission - Set `checkbox`, `radio`, and `switch` `value` property to `on` by default, to match native controls Fixes #289 PiperOrigin-RevId: 381974666
- Relies on `FormDataEvent`, which is supported by Chrome, Firefox, and Edge. - Safari and IE will need a polyfill - Require `disabled` properties on FormElement subclasses - Add `setFormData()` function to control what is added to the Form submission - Set `checkbox` and `radio` `value` property to `on` by default, to match native controls Fixes #289 PiperOrigin-RevId: 381974666
- Relies on `FormDataEvent`, which is supported by Chrome, Firefox, and Edge. - Safari and IE will need a polyfill - Require `disabled` properties on FormElement subclasses - Add `setFormData()` function to control what is added to the Form submission - Set `checkbox` and `radio` `value` property to `on` by default, to match native controls Fixes #289 PiperOrigin-RevId: 381974666
- Relies on `FormDataEvent`, which is supported by Chrome, Firefox, and Edge. - Safari and IE will need a polyfill - Require `disabled` properties on FormElement subclasses - Add `setFormData()` function to control what is added to the Form submission - Set `checkbox` and `radio` `value` property to `on` by default, to match native controls Fixes #289 PiperOrigin-RevId: 381974666
- Relies on `FormDataEvent`, which is supported by Chrome, Firefox, and Edge. - Safari and IE will need a polyfill - Require `disabled` properties on FormElement subclasses - Add `setFormData()` function to control what is added to the Form submission - Set `checkbox` and `radio` `value` property to `on` by default, to match native controls Fixes #289 PiperOrigin-RevId: 381974666
As referenced in #223 (comment), we should ensure that form-ish elements like
<mwc-radio>
and others participate in forms.We should investigate if Form Associated Custom Elements or the FormData event are simpler to integrate and/or polyfill.
The text was updated successfully, but these errors were encountered: