Skip to content

Commit 89fb90e

Browse files
committed
fix: add class is-invalid correclty on error
1 parent 5e6c425 commit 89fb90e

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

projects/xtream/ngx-validation-errors/src/lib/form-field-container.component.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ function toScreamingSnakeCase(input: string): string {
3434
// <input-errors [innerValidationError]="innerValidationError" [messages]="messages" [params]="messageParams"></input-errors>
3535
export class FormFieldContainerComponent implements AfterContentInit, AfterViewInit {
3636

37-
3837
@ContentChild(FormControlName) formControl: FormControlName;
3938
@ContentChild(InputErrorsComponent) public messagesBlock: InputErrorsComponent;
4039

@@ -73,7 +72,6 @@ export class FormFieldContainerComponent implements AfterContentInit, AfterViewI
7372
}
7473

7574
updateErrorComponent() {
76-
console.debug('setting info',this.componentRef, this.formControl.name, this.messages, this.messageParams);
7775
this.addErrorComponent();
7876

7977
if (this.componentRef) {
@@ -87,7 +85,6 @@ export class FormFieldContainerComponent implements AfterContentInit, AfterViewI
8785
@HostBinding('class.has-error')
8886
get hasErrors(): boolean {
8987
const hasError = (!this.formControl.valid && this.formControl.dirty && this.formControl.touched) && !this.validationDisabled;
90-
console.debug('formControl', this.formControl.name, hasError);
9188

9289
if (hasError && this.input && this.input.nativeElement) {
9390
this.messages = Object.keys(this.formControl.errors).map(error => {
@@ -113,17 +110,17 @@ export class FormFieldContainerComponent implements AfterContentInit, AfterViewI
113110
} catch (e) {
114111
}
115112
this.renderer.addClass(this.input.nativeElement, 'is-invalid');
113+
116114
}
117115
this.updateErrorComponent();
118-
console.debug('formControl', this.formControl.name, this.messageParams, this.messages);
119116

120117
return hasError;
121118
}
122119

123120
@HostBinding('class.has-success')
124121
get hasSuccess(): boolean {
125122
const hasSuccess = (
126-
!this.formControl.valid &&
123+
this.formControl.valid &&
127124
this.formControl.dirty && this.formControl.touched) &&
128125
!this.validationDisabled;
129126
if (hasSuccess && this.input && this.input.nativeElement) {

0 commit comments

Comments
 (0)