Re: [w3c/webcomponents] Need callback for form submit data (#187)

I'm trying to build a form-associated web component and I've been able to get the example up and running.
But I'm not sure how to implement custom validation:
Let's say want to build a material design textfield and want to make it a drop-in replacement for existing <input type="text"> tag.
When the user submits a form with my textfield in it I'd like to report the validation in a custom way (red text below the input) instead of using the default browser tooltip.
So I'd expect to be able to plug my custom reportValidation() method into the internals so that it will get called instead of the default impl.
Right now I just can set the validity on the internals which is the wrong way round.
The custom element knows how to report validity, especially when it comes to composed / compound fields.
So I'd expect something along these lines:
this.internals = this.attachInternals();
this.internals.reportValidity = myReportValidityFunction
this.internals.checkValidity = myCheckValidityFunction

It will be interesting to see how this will get implemented from the MWC team:
https://github.com/material-components/material-components-web-components/issues/971

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/187#issuecomment-617818363

Received on Wednesday, 22 April 2020 14:37:35 UTC