Skip to content

Commit 410cfc9

Browse files
authored
fix(slider): properly adjusting bounds #13403 (#13473)
1 parent 6752d56 commit 410cfc9

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

projects/igniteui-angular/src/lib/slider/slider.component.spec.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,8 @@ describe('IgxSlider', () => {
449449
});
450450
});
451451

452-
it('should switch from lower to upper thumb and vice versa when the lower value is equal to the upper one', () => {
452+
// K.D. Removing this functionality because of 0 benefit and lots of issues.
453+
xit('should switch from lower to upper thumb and vice versa when the lower value is equal to the upper one', () => {
453454
slider.value = {
454455
lower: 60,
455456
upper: 60

projects/igniteui-angular/src/lib/slider/slider.component.ts

+18-18
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,7 @@ export class IgxSliderComponent implements
889889
const adjustedValue = this.valueInRange(value, this.lowerBound, this.upperBound);
890890
if (this._lowerValue !== adjustedValue) {
891891
this._lowerValue = adjustedValue;
892+
this.lowerValueChange.emit(this._lowerValue);
892893
this.value = { lower: this._lowerValue, upper: this._upperValue };
893894
}
894895
}
@@ -927,6 +928,7 @@ export class IgxSliderComponent implements
927928
const adjustedValue = this.valueInRange(value, this.lowerBound, this.upperBound);
928929
if (this._upperValue !== adjustedValue) {
929930
this._upperValue = adjustedValue;
931+
this.upperValueChange.emit(this._upperValue);
930932
this.value = { lower: this._lowerValue, upper: this._upperValue };
931933
}
932934
}
@@ -1122,28 +1124,26 @@ export class IgxSliderComponent implements
11221124

11231125
if (this.isRange) {
11241126
if (thumbType === SliderHandle.FROM) {
1125-
const newLower = this.lowerValue + value;
1126-
if (newLower >= this.lowerBound && newLower <= this.upperValue) {
1127-
this._lowerValue = newLower;
1128-
this.lowerValueChange.emit(this._lowerValue);
1127+
if (this.lowerValue + value > this.upperValue) {
1128+
this.upperValue = this.lowerValue + value;
11291129
}
1130+
this.lowerValue += value;
11301131
} else {
1131-
const newUpper = this.upperValue + value;
1132-
if (newUpper <= this.upperBound && newUpper >= this.lowerValue) {
1133-
this._upperValue = newUpper;
1134-
this.upperValueChange.emit(this._upperValue);
1132+
if (this.upperValue + value < this.lowerValue) {
1133+
this.lowerValue = this.upperValue + value;
11351134
}
1135+
this.upperValue += value;
11361136
}
11371137

11381138
const newVal: IRangeSliderValue = {
1139-
lower: this._lowerValue,
1140-
upper: this._upperValue
1139+
lower: this.lowerValue,
1140+
upper: this.upperValue
11411141
}
11421142

11431143
// Swap the thumbs if a collision appears.
1144-
if (newVal.lower == newVal.upper) {
1145-
this.toggleThumb();
1146-
}
1144+
// if (newVal.lower == newVal.upper) {
1145+
// this.toggleThumb();
1146+
// }
11471147

11481148
this.value = newVal;
11491149

@@ -1235,11 +1235,11 @@ export class IgxSliderComponent implements
12351235
return this._el.nativeElement.getBoundingClientRect().width / (this.maxValue - this.minValue) * this.step;
12361236
}
12371237

1238-
private toggleThumb() {
1239-
return this.thumbFrom.isActive ?
1240-
this.thumbTo.nativeElement.focus() :
1241-
this.thumbFrom.nativeElement.focus();
1242-
}
1238+
// private toggleThumb() {
1239+
// return this.thumbFrom.isActive ?
1240+
// this.thumbTo.nativeElement.focus() :
1241+
// this.thumbFrom.nativeElement.focus();
1242+
// }
12431243

12441244
private valueInRange(value, min = 0, max = 100) {
12451245
return Math.max(Math.min(value, max), min);

0 commit comments

Comments
 (0)