You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order to quickly validate if a form is valid, I use the form's checkValidity() function. The browser will go through all the form's elements and check for their validity. This works well for most of the field components except for a required SelectField component. An empty SelectField with a required property and an empty value is seen as valid.
NOTE: this is with v1 (I didn't try with v2 since we are not ready to move to v2 yet).
if ( this.ref.current.checkValidity() ) {
// valid
} else {
// not valid and report error..
}
Expected behavior:
Should report the select field as invalid because it's required and empty.
Desktop:
OS: [macOS Catalina]
Browser [Chrome]
Version [89.0.4389.82]
Additional info:
After debugging the code, I realized that the hidden input field (in SelectFieldInput) used to maintain the value is not mark as required. After testing that, the form's checkValidity still reports it as valid because it's a type hidden. Changing manually the type to a text field with a display:none style did the trick.
So it seems the fixes are:
SelectFieldToggle should pass the required property to SelectInputField.
SelectInputField should use a text form field, with the required attribute set and a style with display:none (likely also an aria-hidden is needed here).
The text was updated successfully, but these errors were encountered:
Description:
In order to quickly validate if a form is valid, I use the form's
checkValidity()
function. The browser will go through all the form's elements and check for their validity. This works well for most of the field components except for a requiredSelectField
component. An emptySelectField
with arequired
property and an emptyvalue
is seen as valid.NOTE: this is with
v1
(I didn't try with v2 since we are not ready to move tov2
yet).To Reproduce:
And later on...
Expected behavior:
Should report the select field as invalid because it's required and empty.
Desktop:
Additional info:
After debugging the code, I realized that the
hidden
input field (inSelectFieldInput
) used to maintain the value is not mark asrequired
. After testing that, the form'scheckValidity
still reports it as valid because it's a typehidden
. Changing manually the type to atext
field with adisplay:none
style did the trick.So it seems the fixes are:
SelectFieldToggle
should pass therequired
property toSelectInputField
.SelectInputField
should use atext
form field, with therequired
attribute set and astyle
withdisplay:none
(likely also anaria-hidden
is needed here).The text was updated successfully, but these errors were encountered: