diff --git a/src/mantine-core/src/Slider/utils/get-change-value/get-change-value.ts b/src/mantine-core/src/Slider/utils/get-change-value/get-change-value.ts index a18af5f0561..d9bb77bb07a 100644 --- a/src/mantine-core/src/Slider/utils/get-change-value/get-change-value.ts +++ b/src/mantine-core/src/Slider/utils/get-change-value/get-change-value.ts @@ -19,11 +19,12 @@ export function getChangeValue({ ? value : Math.min(Math.max(value, 0), containerWidth) / containerWidth; const dx = left * (max - min); - const minIsNegative = min <= 0; - const nextValue = - dx !== 0 ? Math.round(dx / step) * step + (minIsNegative ? min : 0) : Math.min(min, 0); - const nextValueWithPrecision = precision ? Number(nextValue.toFixed(precision)) : nextValue; - const finalValue = Math.min(nextValueWithPrecision, max); + const nextValue = (dx !== 0 ? Math.round(dx / step) * step : 0) + min; + const nextValueWithinStep = Math.max(nextValue - (nextValue % step), min); - return finalValue <= min ? min : finalValue; + if (precision !== undefined) { + return Number(nextValueWithinStep.toFixed(precision)); + } + + return nextValueWithinStep; }