Skip to content

Commit

Permalink
Merge pull request #15022 from IgniteUI/ganastasov/fix-15019-master
Browse files Browse the repository at this point in the history
fix(slider): ensure upper thumb reaches maxValue with decimal steps - master
  • Loading branch information
ChronosSF authored Nov 12, 2024
2 parents 573a710 + 2de1b05 commit a197299
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
16 changes: 16 additions & 0 deletions projects/igniteui-angular/src/lib/slider/slider.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,22 @@ describe('IgxSlider', () => {
expect(slider.value.upper).toBe(60);
});

it('should reach max value with upper thumb in RANGE mode with decimal steps', () => {
slider.minValue = 0;
slider.maxValue = 10;
slider.step = 0.1;
slider.type = IgxSliderType.RANGE;
slider.value = { lower: 0, upper: 10 };
fixture.detectChanges();

const toThumb = fixture.nativeElement.querySelector(THUMB_TO_CLASS);
toThumb.focus();

UIInteractions.triggerKeyDownEvtUponElem('ArrowRight', toThumb, true);
fixture.detectChanges();

expect((slider.value as IRangeSliderValue).upper).toBe(10);
});
});

describe('Slider - List View', () => {
Expand Down
6 changes: 3 additions & 3 deletions projects/igniteui-angular/src/lib/slider/slider.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1354,11 +1354,11 @@ export class IgxSliderComponent implements
private normalizeByStep(value: IRangeSliderValue | number) {
if (this.isRange) {
this._value = {
lower: (value as IRangeSliderValue).lower - ((value as IRangeSliderValue).lower % this.step),
upper: (value as IRangeSliderValue).upper - ((value as IRangeSliderValue).upper % this.step)
lower: Math.floor((value as IRangeSliderValue).lower / this.step) * this.step,
upper: Math.floor((value as IRangeSliderValue).upper / this.step) * this.step
};
} else {
this._value = (value as number) - ((value as number) % this.step);
this._value = Math.floor((value as number) / this.step) * this.step;
}
}

Expand Down

0 comments on commit a197299

Please sign in to comment.