USWDS - Bug: Form validation does not work within modal #5858
Labels
Package: Forms
Package: Modal
Status: Triage
We're triaging this issue and grooming if necessary
Type: Bug
A problem in the code
Describe the bug
When a form is within a modal and the submit button (includes
data-close-modal
) is clicked. Client-side validation is ignored and the modal closes without any alerts or the form submitting.A message in the console is logged -
An invalid form control with name='...' is not focusable.
#4953 Related
Steps to reproduce the bug
See https://codepen.io/zhecensus/pen/KKYRLbb
<input minlength="4" maxlength="4" pattern="[0-9]*" />
type=button
totype=submit form='formid'
The modal should close instead of the expected behavior below
Expected Behavior
The browser's built-in validation focuses and prompts the user with an error message.
Related code
No response
Screenshots
System setup
Both Edge and Firefox
Additional context
This is a niche issue, and I came up with two workarounds, if this issue does not have to be resolved.
data-close-modal
button alone. This results in two actions a user must take.Code of Conduct
The text was updated successfully, but these errors were encountered: