Context:
I'm working on a reusable input component that I wanna to integrates with Angular validators and handles all validators based on the formControl state. However, I'm encountering a issue/bug where the state appears to be incorrect (something like state - 1). Interestingly, adding a setTimeout to delay the operation temporarily resolves the issue, Also I tried to pass the formControl as an Input also I tried signal inputs all of them has the same behavior.
Steps Taken:
Create a reusable input component (InputComponent) that only has the input
Create the parent component (HomeComponent) to use the input.
Implement two interfaces in the InputComponent (ControlValueAccessor, Validator).
the implementation of validate(control: AbstractControl): ValidationErrors function should contain the state of the parent form
Input data:
any text in the input
expected result in the validate(control: AbstractControl): ValidationErrors function:
control.errors => min-length
Actual Behavior:
control.errors => required: true
weird stuff:
in the console if I open the control object I will find the errors inside in the correct state