Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Make web components form-friendly #20

Merged
merged 4 commits into from
Jun 12, 2024
Merged

Conversation

wyrmisis
Copy link
Contributor

@wyrmisis wyrmisis commented Jun 3, 2024

Intent

This changeset turns the editor web components into form-associated custom elements, allowing them to work as native form inputs would.

@FIameCaster
Copy link
Owner

I added a formResetCallback too.

The only thing missing now is validation. I tried calling ElementInternals.setValidity(), passing the textarea's validity and message. This works, but I also had to make the web component focusable with a tab-index. Since the web component itself isn't interactive, making it focusable makes little sense.

Either way, textarea elements will always validate unless you add attributes like minlength, maxlength, or required or set a custom validation message, so I think it's fine if the web component has no validation.

If you don't use any of the web components or setups, and use createEditor() instead, you can just use the textarea as the form element directly.

@FIameCaster
Copy link
Owner

This seems good enough for now.

Thank you for contributing!

@FIameCaster FIameCaster merged commit 7c8a766 into FIameCaster:main Jun 12, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants