igniteui-angular icon indicating copy to clipboard operation
igniteui-angular copied to clipboard

In Angular form invalid inputs do not have red border on submit

Open Marina-L-Stoyanova opened this issue 5 months ago • 4 comments

Description

We have a simple form with a required input. Without interacting with the inputs I click on the send button. The validation messages appear, but the input is not colored in red.

  • igniteui-angular version:
  • browser:

Steps to reproduce

  1. Use the attached sample, or create one with AppBuilder containing simple form
  2. Generate the app
  3. When the form loads click on the Submit button

Result

The validation message appears, but the input is not colored in red

Expected result

the Required input should have red border

Attachments

Attach a sample if available, and screenshots, if applicable.

Image

Sample:

angular-standalone-touched.zip

Marina-L-Stoyanova avatar Sep 04 '25 12:09 Marina-L-Stoyanova

I think is the same as https://github.com/IgniteUI/igniteui-angular/issues/15977

hanastasov avatar Sep 04 '25 15:09 hanastasov

After further investigation I noticed, that if you click in the input once it doesn't change the border color, if you click again the border color will change.

Marina-L-Stoyanova avatar Sep 09 '25 08:09 Marina-L-Stoyanova

I think that this issue is not with the input group component or the input directive. The directive recalculates validity only when certain events fire - value changes, blur, or ngControl status changes:

Image

If you need to re-check the form, you should trigger a status recalculation on each control before asserting validity:

if (this.categoryDtoFormModel.invalid)
  for (const ctrl of Object.values(this.categoryDtoFormModel.controls)) {
    ctrl.markAsTouched();
    ctrl.updateValueAndValidity();
  }
}

Please note that this code works only for a flat form group. For nested groups, it should be called recursively.

viktorkombov avatar Sep 09 '25 13:09 viktorkombov

There has been no recent activity and this issue has been marked inactive.

github-actions[bot] avatar Dec 10 '25 00:12 github-actions[bot]