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

Bind Input [Group] validity directly to ngModel so it responds better to changes through API

Open damyanpetev opened this issue 6 years ago • 14 comments

Preface: The visual validity of a control (as displayed to the user) is a combination of the status and usually either dirty or touched, per Form Validation.

Is your request related to a problem? Please describe.

Updating FormControl properties such as touched/dirty through API (like you might to trigger manual form validation) won't reflect in the Input and Group state, despite causing other validation messages to be displayed.

Currently the validity of the igxInput (and thus the Input Group) is updated based on the AbstractControl.statusChanges. And blur. And focus. https://github.com/IgniteUI/igniteui-angular/blob/7e91e63f844fa27d45e665d64e46b47f464d4e58/projects/igniteui-angular/src/lib/directives/input/input.directive.ts#L211-L213

However, this doesn't quite cover the condition for validity and there are no other events for changes in touched/dirty control state.

Describe alternatives you've considered

An additional call to updateValueAndValidity to ensure the event is emitted and the Input updates: https://github.com/IgniteUI/igniteui-angular/issues/4756#issuecomment-571684611.

Describe the solution you'd like

While that's not a major issue, it'd be better if we do away with the subscription and directly bind the input validity and group styling to the ngModel properties.

Additional context

Because the initial value bind already determined the status, the ngModel control starts out as pristine and invalid and so igxInput.valid is IgxInputState.INITIAL. At this point calling markAsTouched() or markAsDirty() technically completes the requirement for a visual error (and error messages do appear), but there's no statusChanges so the input state and group styling remain initial.

damyanpetev avatar Jan 09 '20 14:01 damyanpetev

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

github-actions[bot] avatar May 10 '20 00:05 github-actions[bot]

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

github-actions[bot] avatar Jul 18 '20 00:07 github-actions[bot]

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

github-actions[bot] avatar Sep 18 '20 00:09 github-actions[bot]

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

github-actions[bot] avatar Nov 18 '20 00:11 github-actions[bot]

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

github-actions[bot] avatar Jan 18 '21 00:01 github-actions[bot]

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

github-actions[bot] avatar Mar 20 '21 00:03 github-actions[bot]

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

github-actions[bot] avatar May 22 '21 00:05 github-actions[bot]

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

github-actions[bot] avatar Jul 25 '21 00:07 github-actions[bot]

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

github-actions[bot] avatar Sep 25 '21 00:09 github-actions[bot]

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

github-actions[bot] avatar Nov 27 '21 00:11 github-actions[bot]

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

github-actions[bot] avatar Jan 27 '22 00:01 github-actions[bot]

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

github-actions[bot] avatar Mar 29 '22 00:03 github-actions[bot]

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

github-actions[bot] avatar May 29 '22 00:05 github-actions[bot]

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

github-actions[bot] avatar Jul 29 '22 00:07 github-actions[bot]

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

github-actions[bot] avatar Sep 28 '22 00:09 github-actions[bot]

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

github-actions[bot] avatar Nov 28 '22 00:11 github-actions[bot]