Skip to content

Commit

Permalink
fix(material/timepicker): deserialize ControlValueAccessor values cor…
Browse files Browse the repository at this point in the history
…rectly (angular#30149)

Fixes that the timepicker was clobbering otherwise parseable values when they're assigned through the `ControlValueAccessor`.

Fixes angular#30140.
  • Loading branch information
crisbeto authored Dec 10, 2024
1 parent e935d0b commit f7d787b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/material/timepicker/timepicker-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ export class MatTimepickerInput<D> implements ControlValueAccessor, Validator, O
* @docs-private
*/
writeValue(value: any): void {
this.value.set(this._dateAdapter.getValidDateOrNull(value));
// Note that we need to deserialize here, rather than depend on the value change effect,
// because `getValidDateOrNull` will clobber the value if it's parseable, but not created by
// the current adapter (see #30140).
const deserialized = this._dateAdapter.deserialize(value);
this.value.set(this._dateAdapter.getValidDateOrNull(deserialized));
}

/**
Expand Down

0 comments on commit f7d787b

Please sign in to comment.