fix(datepicker): mark input tocuhed on calendar date selected (#6007)

* fix(datepicker): mark input tocuhed on calendar date selected

* add test
This commit is contained in:
mmalerba
2017-08-01 14:17:33 -07:00
committed by tinayuangao
parent 3c19234d35
commit 21e9768035
2 changed files with 16 additions and 0 deletions
+1
View File
@@ -212,6 +212,7 @@ export class MdDatepickerInput<D> implements AfterContentInit, ControlValueAcces
this._datepicker.selectedChanged.subscribe((selected: D) => {
this.value = selected;
this._cvaOnChange(selected);
this._onTouched();
this.dateInput.emit(new MdDatepickerInputEvent(this, this._elementRef.nativeElement));
this.dateChange.emit(new MdDatepickerInputEvent(this, this._elementRef.nativeElement));
});
+15
View File
@@ -411,6 +411,21 @@ describe('MdDatepicker', () => {
expect(inputEl.classList).toContain('ng-touched');
});
it('should mark input touched on calendar selection', () => {
let inputEl = fixture.debugElement.query(By.css('input')).nativeElement;
expect(inputEl.classList).toContain('ng-untouched');
testComponent.datepicker._selectAndClose(new Date(2017, JAN, 1));
fixture.detectChanges();
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(inputEl.classList).toContain('ng-touched');
});
});
});
describe('datepicker with formControl', () => {