Skip to content

Commit

Permalink
fix(Slider): markStep & markDigits min/max values
Browse files Browse the repository at this point in the history
markStep and markDigits crashed when < 0
  • Loading branch information
zettca authored and plagoa committed Dec 12, 2024
1 parent 5d14905 commit 2cc9317
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/core/src/Slider/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const calculateStepValue = (
*
* @param {Object} markProperties - The object provided by the user with
* the desired configuration for the marks.
* @param {Integer} markstep - The separation between marks.
* @param {Integer} markStep - The separation between marks.
* @param {Integer} divisionQuantity - How many subdivisions there are in the slider.
* @param {Integer} minPointValue - The value of the first point in the slider from
* left to right.
Expand All @@ -123,7 +123,7 @@ export const calculateStepValue = (
*/
export const createMark = (
markProperties: HvMarkProperty[],
markstep: number,
markStep: number,
divisionQuantity: number,
minPointValue: number,
maxPointValue: number,
Expand Down Expand Up @@ -156,14 +156,14 @@ export const createMark = (
}
});
} else {
const roundedMarkStep = Math.floor(markstep);
const roundedMarkStep = Math.max(1, Math.floor(markStep));

for (let index = 0; index <= divisionQuantity; index += roundedMarkStep) {
let labelValue: React.ReactNode = knobsPositionToScaledValue(
index,
minPointValue,
stepValue,
).toFixed(markDigits);
).toFixed(Math.max(0, Math.min(8, markDigits)));

values.push(labelValue as string);
labelValue = formatMark?.(labelValue) || labelValue;
Expand Down

0 comments on commit 2cc9317

Please sign in to comment.