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 issue #40. #82

Merged
merged 1 commit into from
Sep 15, 2022
Merged

Fix issue #40. #82

merged 1 commit into from
Sep 15, 2022

Conversation

sipris
Copy link
Contributor

@sipris sipris commented Sep 12, 2022

Listen for submit events on the closest submit button and if the form is invalid prevent the default handling.
For more information see this explanation.

Listen for submit events on the closest submit button
and if the form is invalid prevent the default handling.
Copy link
Owner

@calebdwilliams calebdwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Thanks!

@calebdwilliams calebdwilliams merged commit 3fc7dc1 into calebdwilliams:main Sep 15, 2022
const internals = internalsMap.get(node);
return internals.reportValidity();
});
form.addEventListener('click', event => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice and it does work for most use cases. But forms can be submitted with other events (like typing "Enter" in a field). So, we need to also keep in mind those use cases. Do you think opening an issue about this is worth it?

Copy link
Contributor Author

@sipris sipris Sep 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx, for the annotation. However, according to the spec, hitting enter in a field causes "the user agent to fire a click event at that default button."

EDIT:
If it is wanted to force this behavior on custom elements, then a new issue is certainly worth it.

There is an ongoing discussion regarding faCE and implicit submission WICG Issue 815. I would wait for a decision.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While pressing enter in an input field, this doesn't necessarily hold true for FACE elements, FWIW. I think this is fine as is. If you do happen upon any use cases, open an issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. This does works nicely!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants