Validation Flaws in IxInput: Immediate Error Display and Documentation Workaround Problems #1638
Open
2 tasks done
Labels
triage
We discuss this topic in our internal weekly
Prerequisites
Bug Report: Validation Flaws in IxInput: Immediate Error Display and Documentation Workaround Problems
Description
I have tested the new
IxInput
elements and discovered that the required form validation is displayed immediately upon the first render.This behavior is problematic because it does not allow for customization of validation behavior in forms, which is possible in pure Angular or other libraries. Typically, developers can customize when validation messages appear, such as by rendering them only after a field is touched or dirty.
Comparison with Angular Material
For reference, Angular Material provides an
errorStateMatcher
to tweak validation behavior. By default, Angular Material only displays validation messages when a field is dirty or touched. This provides better control and user experience.Problems with Suggested Workaround
The suggested workaround in the documentation introduces additional issues:
Incorrect Validation State:
Misleading Feedback Messages:
Buggy Behavior in Example Code:
!control.untouched
leads to unexpected behavior. For example:Adjusting the
CustomRequiredValidator
to rely on!pristine
is also insufficient, and conditionally setting validation messages does not resolve the issue, as it still displays incorrect valid feedback (refer to my repository for more details).Expected Behavior
The required validation messages for
IxInput
should:errorStateMatcher
.Suggested Solution
errorStateMatcher
.What type of frontend framework are you seeing the problem on?
Angular
Which version of iX do you use?
v2.6.1
Code to produce this issue.
I have created a github repository linked to stackblitz in the README to demonstrate these behaviors.
The demo shows four different examples of required fields, these are:
RequiredValidator
with therequired
HTML attribute. This demonstrates thatIxInput
is broken for theRequiredValidator
.CustomRequiredValidator
. This highlights that the suggested solution from the documentation is flawed, as it allows submission of an empty form and shows incorrect valid feedback.CustomRequiredValidator
from the documentation. This shows that adjusting theCustomRequiredValidator
to rely on!pristine
is insufficient and that setting validation messages conditionally does not resolve the issue.The text was updated successfully, but these errors were encountered: