Skip to content

Commit

Permalink
fix(material/progress-bar): add coercion for number inputs (#25585)
Browse files Browse the repository at this point in the history
* fix(material/progress-bar): add coercion for number inputs

* fixup! fix(material/progress-bar): add coercion for number inputs
  • Loading branch information
mmalerba committed Sep 7, 2022
1 parent 3bca23d commit 9331866
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/material/progress-bar/progress-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
MAT_LEGACY_PROGRESS_BAR_DEFAULT_OPTIONS,
LegacyProgressAnimationEnd,
} from '@angular/material/legacy-progress-bar';
import {coerceNumberProperty, NumberInput} from '@angular/cdk/coercion';

// Boilerplate for applying mixins to MatProgressBar.
/** @docs-private */
Expand Down Expand Up @@ -96,8 +97,8 @@ export class MatProgressBar
get value(): number {
return this._value;
}
set value(v: number) {
this._value = clamp(v || 0);
set value(v: NumberInput) {
this._value = clamp(coerceNumberProperty(v));
this._changeDetectorRef.markForCheck();
}
private _value = 0;
Expand All @@ -107,8 +108,8 @@ export class MatProgressBar
get bufferValue(): number {
return this._bufferValue || 0;
}
set bufferValue(v: number) {
this._bufferValue = clamp(v || 0);
set bufferValue(v: NumberInput) {
this._bufferValue = clamp(coerceNumberProperty(v));
this._changeDetectorRef.markForCheck();
}
private _bufferValue = 0;
Expand Down
5 changes: 3 additions & 2 deletions tools/public_api_guard/material/progress-bar.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { MAT_LEGACY_PROGRESS_BAR_LOCATION_FACTORY as MAT_PROGRESS_BAR_LOCATION_F
import { MatLegacyProgressBarDefaultOptions as MatProgressBarDefaultOptions } from '@angular/material/legacy-progress-bar';
import { MatLegacyProgressBarLocation as MatProgressBarLocation } from '@angular/material/legacy-progress-bar';
import { NgZone } from '@angular/core';
import { NumberInput } from '@angular/cdk/coercion';
import { OnDestroy } from '@angular/core';
import { LegacyProgressAnimationEnd as ProgressAnimationEnd } from '@angular/material/legacy-progress-bar';

Expand All @@ -35,7 +36,7 @@ export class MatProgressBar extends _MatProgressBarBase implements AfterViewInit
// (undocumented)
_animationMode?: string | undefined;
get bufferValue(): number;
set bufferValue(v: number);
set bufferValue(v: NumberInput);
_getBufferBarFlexBasis(): string;
_getPrimaryBarTransform(): string;
_isIndeterminate(): boolean;
Expand All @@ -47,7 +48,7 @@ export class MatProgressBar extends _MatProgressBarBase implements AfterViewInit
// (undocumented)
ngOnDestroy(): void;
get value(): number;
set value(v: number);
set value(v: NumberInput);
// (undocumented)
static ɵcmp: i0.ɵɵComponentDeclaration<MatProgressBar, "mat-progress-bar", ["matProgressBar"], { "color": "color"; "value": "value"; "bufferValue": "bufferValue"; "mode": "mode"; }, { "animationEnd": "animationEnd"; }, never, never, false>;
// (undocumented)
Expand Down

0 comments on commit 9331866

Please sign in to comment.