Skip to content

Commit 9331866

Browse files
authored
fix(material/progress-bar): add coercion for number inputs (#25585)
* fix(material/progress-bar): add coercion for number inputs * fixup! fix(material/progress-bar): add coercion for number inputs
1 parent 3bca23d commit 9331866

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/material/progress-bar/progress-bar.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
MAT_LEGACY_PROGRESS_BAR_DEFAULT_OPTIONS,
2929
LegacyProgressAnimationEnd,
3030
} from '@angular/material/legacy-progress-bar';
31+
import {coerceNumberProperty, NumberInput} from '@angular/cdk/coercion';
3132

3233
// Boilerplate for applying mixins to MatProgressBar.
3334
/** @docs-private */
@@ -96,8 +97,8 @@ export class MatProgressBar
9697
get value(): number {
9798
return this._value;
9899
}
99-
set value(v: number) {
100-
this._value = clamp(v || 0);
100+
set value(v: NumberInput) {
101+
this._value = clamp(coerceNumberProperty(v));
101102
this._changeDetectorRef.markForCheck();
102103
}
103104
private _value = 0;
@@ -107,8 +108,8 @@ export class MatProgressBar
107108
get bufferValue(): number {
108109
return this._bufferValue || 0;
109110
}
110-
set bufferValue(v: number) {
111-
this._bufferValue = clamp(v || 0);
111+
set bufferValue(v: NumberInput) {
112+
this._bufferValue = clamp(coerceNumberProperty(v));
112113
this._changeDetectorRef.markForCheck();
113114
}
114115
private _bufferValue = 0;

tools/public_api_guard/material/progress-bar.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { MAT_LEGACY_PROGRESS_BAR_LOCATION_FACTORY as MAT_PROGRESS_BAR_LOCATION_F
1919
import { MatLegacyProgressBarDefaultOptions as MatProgressBarDefaultOptions } from '@angular/material/legacy-progress-bar';
2020
import { MatLegacyProgressBarLocation as MatProgressBarLocation } from '@angular/material/legacy-progress-bar';
2121
import { NgZone } from '@angular/core';
22+
import { NumberInput } from '@angular/cdk/coercion';
2223
import { OnDestroy } from '@angular/core';
2324
import { LegacyProgressAnimationEnd as ProgressAnimationEnd } from '@angular/material/legacy-progress-bar';
2425

@@ -35,7 +36,7 @@ export class MatProgressBar extends _MatProgressBarBase implements AfterViewInit
3536
// (undocumented)
3637
_animationMode?: string | undefined;
3738
get bufferValue(): number;
38-
set bufferValue(v: number);
39+
set bufferValue(v: NumberInput);
3940
_getBufferBarFlexBasis(): string;
4041
_getPrimaryBarTransform(): string;
4142
_isIndeterminate(): boolean;
@@ -47,7 +48,7 @@ export class MatProgressBar extends _MatProgressBarBase implements AfterViewInit
4748
// (undocumented)
4849
ngOnDestroy(): void;
4950
get value(): number;
50-
set value(v: number);
51+
set value(v: NumberInput);
5152
// (undocumented)
5253
static ɵcmp: i0.ɵɵComponentDeclaration<MatProgressBar, "mat-progress-bar", ["matProgressBar"], { "color": "color"; "value": "value"; "bufferValue": "bufferValue"; "mode": "mode"; }, { "animationEnd": "animationEnd"; }, never, never, false>;
5354
// (undocumented)

0 commit comments

Comments
 (0)