mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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:
@@ -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));
|
||||
});
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user