Skip to content

Commit 600a8b0

Browse files
committed
fix(material/timepicker): deserialize ControlValueAccessor values correctly (#30149)
Fixes that the timepicker was clobbering otherwise parseable values when they're assigned through the `ControlValueAccessor`. Fixes #30140. (cherry picked from commit f7d787b)
1 parent f8cf936 commit 600a8b0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/material/timepicker/timepicker-input.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,11 @@ export class MatTimepickerInput<D> implements ControlValueAccessor, Validator, O
178178
* @docs-private
179179
*/
180180
writeValue(value: any): void {
181-
this.value.set(this._dateAdapter.getValidDateOrNull(value));
181+
// Note that we need to deserialize here, rather than depend on the value change effect,
182+
// because `getValidDateOrNull` will clobber the value if it's parseable, but not created by
183+
// the current adapter (see #30140).
184+
const deserialized = this._dateAdapter.deserialize(value);
185+
this.value.set(this._dateAdapter.getValidDateOrNull(deserialized));
182186
}
183187

184188
/**

0 commit comments

Comments
 (0)