Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3550 Fixed an issue with the initial validation fix. #3603

Merged
merged 5 commits into from
Jan 16, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(false);
expect(igxInput.valid).toBe(IgxInputState.INITIAL);

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