Skip to content

Commit

Permalink
[@mantine/core] Slider: Fix incorrect min/max values handling (#2839)
Browse files Browse the repository at this point in the history
* [@mantine/core] Select: only use open/close callback when value changes

* [@mantine/core] Select: do not use early return

* [@mantine/core] Menu - revert PR #2646

* [Mantine/core] Slider: fix min/max values

* [@mantine/core] Slider: remove unneeded story

* [@mantine/core] Slider: revert changes to minmax story
  • Loading branch information
wes337 committed Nov 2, 2022
1 parent 168394e commit 7623acb
Showing 1 changed file with 7 additions and 6 deletions.
Expand Up @@ -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;
}

0 comments on commit 7623acb

Please sign in to comment.