Skip to content

Commit 28e6623

Browse files
Don't convert to int to convert back to string
1 parent dfe2ede commit 28e6623

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

packages/uui-range-slider/lib/uui-range-slider.element.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ const CountDecimalPlaces = (num: number) => {
2121
return decimalIndex >= 0 ? num.toString().length - decimalIndex - 1 : 0;
2222
};
2323

24-
const RoundToDecimalPlaces = (target: number, decimalPlaces: number) =>
25-
Number(target.toFixed(decimalPlaces));
26-
2724
// TODO: ability to focus on the range, to enable keyboard interaction to move the range.
2825
// TODO: Ability to click outside a range, to move the range if the maxGap has been reached.
2926
// TODO: .
@@ -634,18 +631,12 @@ export class UUIRangeSliderElement extends UUIFormControlMixin(LitElement, '') {
634631
return html`<div class="thumb-values">
635632
<span
636633
><span
637-
>${RoundToDecimalPlaces(
638-
this._lowInputValue,
639-
CountDecimalPlaces(this._step),
640-
)}</span
634+
>${this._lowInputValue.toFixed(CountDecimalPlaces(this._step))}</span
641635
></span
642636
>
643637
<span
644638
><span
645-
>${RoundToDecimalPlaces(
646-
this._highInputValue,
647-
CountDecimalPlaces(this._step),
648-
)}</span
639+
>${this._highInputValue.toFixed(CountDecimalPlaces(this._step))}</span
649640
></span
650641
>
651642
</div>`;
@@ -679,10 +670,7 @@ export class UUIRangeSliderElement extends UUIFormControlMixin(LitElement, '') {
679670
const stepValues = new Array(stepAmount + 1)
680671
.fill(this._step)
681672
.map(step =>
682-
RoundToDecimalPlaces(
683-
this._min + step * index++,
684-
CountDecimalPlaces(this._step),
685-
),
673+
(this._min + step * index++).toFixed(CountDecimalPlaces(this._step)),
686674
);
687675

688676
return html`<div class="step-values">

0 commit comments

Comments
 (0)