Skip to content

Commit

Permalink
fix(cdk): NativeValidator fix touched state (#8818)
Browse files Browse the repository at this point in the history
  • Loading branch information
waterplea authored Sep 5, 2024
1 parent 7938dd5 commit 2a5e754
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import {timer} from 'rxjs';
selector: '[tuiNativeValidator]',
providers: [tuiProvide(NG_VALIDATORS, TuiNativeValidator, true)],
host: {
'(blur)': 'handleValidation()',
'(focusout)': 'handleValidation()',
},
})
export class TuiNativeValidator implements Validator {
private readonly destroyRef = inject(DestroyRef);
private readonly zone = inject(NgZone);
private readonly host = tuiInjectElement<HTMLInputElement>();
private readonly el = tuiInjectElement<HTMLInputElement>();
private control?: AbstractControl;

@Input()
Expand All @@ -37,8 +37,4 @@ export class TuiNativeValidator implements Validator {
this.control?.touched && this.control?.invalid ? this.tuiNativeValidator : '',
);
}

private get el(): HTMLInputElement {
return this.host.querySelector('input,textarea,select') || this.host;
}
}
2 changes: 0 additions & 2 deletions projects/core/components/textfield/textfield.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
} from '@angular/core';
import {NgControl} from '@angular/forms';
import {WaResizeObserver} from '@ng-web-apis/resize-observer';
import {TuiNativeValidator} from '@taiga-ui/cdk/directives/native-validator';
import {tuiInjectId} from '@taiga-ui/cdk/services';
import type {TuiContext, TuiStringHandler} from '@taiga-ui/cdk/types';
import {tuiInjectElement} from '@taiga-ui/cdk/utils/dom';
Expand Down Expand Up @@ -52,7 +51,6 @@ import {TuiWithTextfieldDropdown} from './textfield-dropdown.directive';
tuiDropdownOptionsProvider({limitWidth: 'fixed'}),
],
hostDirectives: [
TuiNativeValidator,
TuiDropdownDirective,
TuiWithDropdownOpen,
TuiWithTextfieldDropdown,
Expand Down

0 comments on commit 2a5e754

Please sign in to comment.