Skip to content

Commit

Permalink
fix(datepicker): mark input tocuhed on calendar date selected (#6007)
Browse files Browse the repository at this point in the history
* fix(datepicker): mark input tocuhed on calendar date selected

* add test
  • Loading branch information
mmalerba authored and tinayuangao committed Aug 1, 2017
1 parent 3c19234 commit 21e9768
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/datepicker/datepicker-input.ts
Expand Up @@ -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));
});
Expand Down
15 changes: 15 additions & 0 deletions src/lib/datepicker/datepicker.spec.ts
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 21e9768

Please sign in to comment.