Skip to content

Commit 0a0ddcf

Browse files
committedFeb 21, 2025·
fix(material/datepicker): changed after checked error when assigning end value (#30534)
Fixes that there was a hidden "changed after checked" error in the range picker when the secondary value was being assinged without notifying Angular. Fixes #30526. (cherry picked from commit 7ef405c)
1 parent a41bcd4 commit 0a0ddcf

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed
 

‎src/material/datepicker/date-range-input-parts.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ abstract class MatDateRangeInputPartBase<D>
193193
opposite?._validatorOnChange();
194194
}
195195

196+
protected override _formatValue(value: D | null) {
197+
super._formatValue(value);
198+
// Any time the input value is reformatted we need to tell the parent.
199+
this._rangeInput._handleChildValueChange();
200+
}
201+
196202
/** return the ARIA accessible name of the input element */
197203
_getAccessibleName(): string {
198204
return _computeAriaAccessibleName(this._elementRef.nativeElement);
@@ -264,16 +270,10 @@ export class MatStartDate<D> extends MatDateRangeInputPartBase<D> {
264270
if (this._model) {
265271
const range = new DateRange(value, this._model.selection.end);
266272
this._model.updateSelection(range, this);
273+
this._rangeInput._handleChildValueChange();
267274
}
268275
}
269276

270-
protected override _formatValue(value: D | null) {
271-
super._formatValue(value);
272-
273-
// Any time the input value is reformatted we need to tell the parent.
274-
this._rangeInput._handleChildValueChange();
275-
}
276-
277277
override _onKeydown(event: KeyboardEvent) {
278278
const endInput = this._rangeInput._endInput;
279279
const element = this._elementRef.nativeElement;

‎tools/public_api_guard/material/datepicker.md

-2
Original file line numberDiff line numberDiff line change
@@ -828,8 +828,6 @@ export class MatStartDate<D> extends MatDateRangeInputPartBase<D> {
828828
// (undocumented)
829829
protected _assignValueToModel(value: D | null): void;
830830
// (undocumented)
831-
protected _formatValue(value: D | null): void;
832-
// (undocumented)
833831
protected _getValueFromModel(modelValue: DateRange<D>): D | null;
834832
// (undocumented)
835833
_onKeydown(event: KeyboardEvent): void;

0 commit comments

Comments
 (0)
Please sign in to comment.