Skip to content

Commit a0d67c5

Browse files
committed
chore(*): try req logic like this
1 parent ef903c3 commit a0d67c5

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

projects/igniteui-angular/src/lib/directives/input/input.directive.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,6 @@ export class IgxInputDirective implements AfterViewInit, OnDestroy {
9797
@HostBinding('class.igx-input-group__textarea')
9898
public isTextArea = false;
9999

100-
@HostBinding('attr.required')
101-
public get requiredAttribute() {
102-
return this.required ? '' : null;
103-
}
104-
105100
private _valid = IgxInputState.INITIAL;
106101
private _statusChanges$: Subscription;
107102
private _valueChanges$: Subscription;
@@ -217,14 +212,21 @@ export class IgxInputDirective implements AfterViewInit, OnDestroy {
217212
if (this.ngControl && (this.ngControl.control.validator || this.ngControl.control.asyncValidator)) {
218213
validation = this.ngControl.control.validator({} as AbstractControl);
219214
}
220-
return validation && validation.required || (this._externalValidate ?
221-
this.inputGroup.isRequired : !!this._defaultRequired);
215+
let required;
216+
if (validation && validation.required !== undefined) {
217+
required = validation.required;
218+
} else {
219+
required = this.nativeElement.required;
220+
}
221+
return required;
222222
}
223223
public set required(value: boolean) {
224-
if (this._defaultRequired === null) {
225-
this._defaultRequired = value;
226-
}
227-
this.inputGroup.isRequired = value;
224+
this.nativeElement.required = this.inputGroup.isRequired = value;
225+
}
226+
227+
@HostBinding('attr.required')
228+
public get hostBindingRequired(): string {
229+
return this.required ? '' : null;
228230
}
229231

230232
/**

0 commit comments

Comments
 (0)