Skip to content

Commit

Permalink
Merge pull request #3603 from IgniteUI/fix-3550-6.2.x
Browse files Browse the repository at this point in the history
#3550 Fixed an issue with the initial validation fix.
  • Loading branch information
kdinev authored Jan 16, 2019
2 parents a576d44 + a504c7b commit 2853a25
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,21 +200,24 @@ describe('IgxInput', () => {
const igxInput = fixture.componentInstance.igxInput;
const inputElement = fixture.debugElement.query(By.directive(IgxInputDirective)).nativeElement;

const inputGroupElement = fixture.debugElement.query(By.css('igx-input-group')).nativeElement;
expect(inputGroupElement.classList.contains(INPUT_GROUP_INVALID_CSS_CLASS)).toBe(true);
expect(igxInput.valid).toBe(IgxInputState.INVALID);

dispatchInputEvent('focus', inputElement, fixture);
dispatchInputEvent('blur', inputElement, fixture);

const inputGroupElement = fixture.debugElement.query(By.css('igx-input-group')).nativeElement;
expect(inputGroupElement.classList.contains(INPUT_GROUP_INVALID_CSS_CLASS)).toBe(true);
expect(igxInput.valid).toBe(IgxInputState.INVALID);

igxInput.value = 'test';
fixture.componentInstance.value = 'test';
fixture.detectChanges();

expect(inputGroupElement.classList.contains(INPUT_GROUP_INVALID_CSS_CLASS)).toBe(false);
expect(igxInput.valid).toBe(IgxInputState.VALID);


igxInput.value = '';
fixture.componentInstance.value = '';
fixture.detectChanges();

dispatchInputEvent('focus', inputElement, fixture);
Expand Down Expand Up @@ -386,11 +389,12 @@ class DisabledInputComponent {

@Component({ template: `<igx-input-group #igxInputGroup>
<label for="test" igxLabel>Test</label>
<input name="test" #igxInput type="text" igxInput required="required" />
<input name="test" #igxInput type="text" igxInput [value]="value" required="required" />
</igx-input-group>` })
class RequiredInputComponent {
@ViewChild('igxInputGroup') public igxInputGroup: IgxInputGroupComponent;
@ViewChild(IgxInputDirective) public igxInput: IgxInputDirective;
value = '';
}

@Component({ template: `<igx-input-group #igxInputGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import {
Input,
OnDestroy,
Optional,
Self
Self,
OnChanges,
SimpleChanges
} from '@angular/core';
import { AbstractControl, FormControlName, NgControl, NgModel } from '@angular/forms';
import { Subscription } from 'rxjs';
Expand Down Expand Up @@ -295,7 +297,7 @@ export class IgxInputDirective implements AfterViewInit, OnDestroy {
}

private checkValidity() {
if (!this.ngControl && this._hasValidators) {
if (!this.ngControl && this._hasValidators()) {
this._valid = this.nativeElement.checkValidity() ? IgxInputState.VALID : IgxInputState.INVALID;
}
}
Expand Down

0 comments on commit 2853a25

Please sign in to comment.