Skip to content

Commit a197299

Browse files
authored
Merge pull request #15022 from IgniteUI/ganastasov/fix-15019-master
fix(slider): ensure upper thumb reaches maxValue with decimal steps - master
2 parents 573a710 + 2de1b05 commit a197299

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,22 @@ describe('IgxSlider', () => {
637637
expect(slider.value.upper).toBe(60);
638638
});
639639

640+
it('should reach max value with upper thumb in RANGE mode with decimal steps', () => {
641+
slider.minValue = 0;
642+
slider.maxValue = 10;
643+
slider.step = 0.1;
644+
slider.type = IgxSliderType.RANGE;
645+
slider.value = { lower: 0, upper: 10 };
646+
fixture.detectChanges();
647+
648+
const toThumb = fixture.nativeElement.querySelector(THUMB_TO_CLASS);
649+
toThumb.focus();
650+
651+
UIInteractions.triggerKeyDownEvtUponElem('ArrowRight', toThumb, true);
652+
fixture.detectChanges();
653+
654+
expect((slider.value as IRangeSliderValue).upper).toBe(10);
655+
});
640656
});
641657

642658
describe('Slider - List View', () => {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,11 +1354,11 @@ export class IgxSliderComponent implements
13541354
private normalizeByStep(value: IRangeSliderValue | number) {
13551355
if (this.isRange) {
13561356
this._value = {
1357-
lower: (value as IRangeSliderValue).lower - ((value as IRangeSliderValue).lower % this.step),
1358-
upper: (value as IRangeSliderValue).upper - ((value as IRangeSliderValue).upper % this.step)
1357+
lower: Math.floor((value as IRangeSliderValue).lower / this.step) * this.step,
1358+
upper: Math.floor((value as IRangeSliderValue).upper / this.step) * this.step
13591359
};
13601360
} else {
1361-
this._value = (value as number) - ((value as number) % this.step);
1361+
this._value = Math.floor((value as number) / this.step) * this.step;
13621362
}
13631363
}
13641364

0 commit comments

Comments
 (0)