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
Create a ActiveForm with validationOnType = false and validateOnBlur = true.
What is the expected result?
For my understanding, validationDelay shouldn't be used because it states:
number of milliseconds that the validation should be delayed when the user types in the field and [[validateOnType]] is set true. If [[ActiveField::validationDelay]] is set, its value will take precedence for that input field
Configuring the validationDelay property with value 0 or 1 for the widget has no effect.
What do you get instead?
The default validationDelay value defined in yii.activeForm.js is used. Therefore the applied validation delay when creating a ActiveForm with validateOnBlur seems to be 200ms.
Additional info
Cause in code:
In yii.ActiveForm.jswatchAttribute() only in if (attribute.validateOnType) { case the validationDelay value from attribute gets passed to validateAttribute() function:
In validateAttribute function, validationDelay is checked for empty. When empty, 200ms is used instead. When no value is passed validationDelay is empty, consequently 200ms is used in validateOnBlur case:
The delayed validation causes problems when using a screen reader.
When an validation error occours, the error message gets read after the description for the following input field, even when using `aria-live="assertive". After some digging we found out that the 200ms validation delay causes the screen reader to start reading the next focus first instead of directly reading out the error message.
Suggestions to resolve the issue
Idea 1:
Move validation delay from validateAttribute function to watchAttribute function. The validation delay should only be used when attribute.validateOnType is true. So why keep it in validateAttribute funciton that is used in every case?
What steps will reproduce the problem?
Create a ActiveForm with
validationOnType = false
andvalidateOnBlur = true
.What is the expected result?
For my understanding,
validationDelay
shouldn't be used because it states:Configuring the
validationDelay
property with value0
or1
for the widget has no effect.What do you get instead?
The default validationDelay value defined in
yii.activeForm.js
is used. Therefore the applied validation delay when creating a ActiveForm withvalidateOnBlur
seems to be 200ms.Additional info
Cause in code:
In
yii.ActiveForm.js
watchAttribute()
only inif (attribute.validateOnType) {
case the validationDelay value from attribute gets passed tovalidateAttribute()
function:validateOnType:
yii2/framework/assets/yii.activeForm.js
Line 542 in 76150c5
validateOnBlur:
yii2/framework/assets/yii.activeForm.js
Line 532 in 76150c5
In
validateAttribute
function,validationDelay
is checked for empty. When empty, 200ms is used instead. When no value is passedvalidationDelay
is empty, consequently 200ms is used in validateOnBlur case:yii2/framework/assets/yii.activeForm.js
Line 591 in 76150c5
Possible duplicates
Perhaps #18422 adresses the same problem.
Why is this a Problem?
The delayed validation causes problems when using a screen reader.
When an validation error occours, the error message gets read after the description for the following input field, even when using `aria-live="assertive". After some digging we found out that the 200ms validation delay causes the screen reader to start reading the next focus first instead of directly reading out the error message.
Suggestions to resolve the issue
Idea 1:
Move validation delay from
validateAttribute
function towatchAttribute
function. The validation delay should only be used when attribute.validateOnType is true. So why keep it in validateAttribute funciton that is used in every case?Code would look something like this then:
Idea 2:
Specify a default value for
validateAttribute
'svalidationDelay
parameter.The text was updated successfully, but these errors were encountered: