mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
fix(range): clamp values that are out of bounds (#17623)
* fix(range): clamp out of bounds values, add tests * lint files
This commit is contained in:
@ -126,9 +126,27 @@ export class Range implements ComponentInterface {
|
||||
if (!this.noUpdate) {
|
||||
this.updateRatio();
|
||||
}
|
||||
|
||||
value = this.ensureValueInBounds(value);
|
||||
|
||||
this.ionChange.emit({ value });
|
||||
}
|
||||
|
||||
private clampBounds = (value: any): number => {
|
||||
return clamp(this.min, value, this.max);
|
||||
}
|
||||
|
||||
private ensureValueInBounds = (value: any) => {
|
||||
if (this.dualKnobs) {
|
||||
return {
|
||||
lower: this.clampBounds(value.lower),
|
||||
upper: this.clampBounds(value.upper)
|
||||
};
|
||||
} else {
|
||||
return this.clampBounds(value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Emitted when the value property has changed.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user