diff --git a/packages/mosaic/timepicker/timepicker.spec.ts b/packages/mosaic/timepicker/timepicker.spec.ts index b9860bcd0..ac4a8ccf7 100644 --- a/packages/mosaic/timepicker/timepicker.spec.ts +++ b/packages/mosaic/timepicker/timepicker.spec.ts @@ -221,6 +221,31 @@ describe('McTimepicker', () => { 'broken fallback to default time format'); }); }); + + it('When the format updates', () => { + testComponent.timeFormat = 'HH:mm:ss'; + testComponent.timeValue = moment('1970-01-01 00:00:00'); + fixture.detectChanges(); + + return fixture.whenStable() + .then(() => { + expect(inputElementDebug.nativeElement.value).toBe( + '00:00:00', + 'mismatch time format' + ); + + testComponent.timeFormat = 'HH:mm'; + fixture.detectChanges(); + + return fixture.whenStable(); + }) + .then(() => { + expect(inputElementDebug.nativeElement.value).toBe( + '00:00', + 'mismatch time format' + ); + }); + }); }); describe('Convert user input', () => { diff --git a/packages/mosaic/timepicker/timepicker.ts b/packages/mosaic/timepicker/timepicker.ts index bbe106b66..10e126652 100644 --- a/packages/mosaic/timepicker/timepicker.ts +++ b/packages/mosaic/timepicker/timepicker.ts @@ -201,8 +201,9 @@ export class McTimepicker extends McTimepickerMixinBase .map((timeFormatKey) => TimeFormats[timeFormatKey]) .indexOf(formatValue) > -1 ? formatValue : DEFAULT_TIME_FORMAT; - (this.ngControl.control as FormControl).updateValueAndValidity(); this.placeholder = TIMEFORMAT_PLACEHOLDERS[this._timeFormat]; + + setTimeout(() => this.applyInputChanges({ doTimestringReformat: true })); } private _timeFormat: TimeFormats;