Skip to content

Commit 0d72cd6

Browse files
authored
feat(timepicker): allow null value and change validation state on manual update (#3084)
1 parent 7616362 commit 0d72cd6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/timepicker/timepicker.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
parseTime,
2828
isInputValid
2929
} from './timepicker.utils';
30+
import { fakeAsync } from '@angular/core/testing';
3031

3132
export const TIMEPICKER_CONTROL_VALUE_ACCESSOR: any = {
3233
provide: NG_VALUE_ACCESSOR,
@@ -205,6 +206,7 @@ export class TimepickerComponent
205206
_updateTime() {
206207
const _seconds = this.showSeconds ? this.seconds : void 0;
207208
if (!isInputValid(this.hours, this.minutes, _seconds, this.isPM())) {
209+
this.isValid.emit(false);
208210
this.onChange(null);
209211

210212
return;
@@ -239,6 +241,8 @@ export class TimepickerComponent
239241
writeValue(obj: any): void {
240242
if (isValidDate(obj)) {
241243
this._store.dispatch(this._timepickerActions.writeValue(parseTime(obj)));
244+
} else if (obj == null) {
245+
this._store.dispatch(this._timepickerActions.writeValue(null));
242246
}
243247
}
244248

0 commit comments

Comments
 (0)