-
-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Slider] Ends are unreachable with mouse drags #1360
Comments
Thanks for reporting this @SimeonRolev This would be caused by #1219, I think we need to round the position values when the pointer is released |
@mj12albert That's what I initially thought of as a workaround and I gave it a shot yesterday, utilizing the Unfortunately, I don't think it's optimal. A user sets a slider's value during a mouse drag and seeing the slider re-adjust on its own upon mouse release is awkward - even if it happens only at the edges. Makes you not trust the component - did it only glitch visually or did it slightly tweak my value, too? const MySlider = (props) => {
const ref = useRef(null);
const onValueCommitted = (value, event) => {
handleEdges();
return props.onValueCommitted?.(value, event);
};
const handleEdges = () => {
if (props.orientation === 'vertical') return;
const thumbNode = ref.current.querySelector('.thumb');
if (!thumbNode) return;
const cssValue = thumbNode.style.insetInlineStart;
if (cssValue.endsWith('%')) {
const value = Number(cssValue.substring(0, cssValue.length - 1)); // remove % sign
if (value < 1) thumbNode.style.insetInlineStart = '0%';
if (value > 99) thumbNode.style.insetInlineStart = '100%';
}
};
return (
<div ref={ref}>
<Slider.Root
{...props}
onValueCommitted={onValueCommitted}
>
<Slider.Control>
<Slider.Track>
<Slider.Thumb className='thumb' />
</Slider.Track>
</Slider.Control>
</Slider.Root>
</div>
);
}; |
One more example of the UI not respecting the steps of the slider properly: Screencast.from.28.01.2025.11.38.09.webm |
Is this a regression from https://mui.com/base-ui/react-slider/? Are we missing a test case from MUI Base? |
It was caused by #1219 which changed the thumb styles to be based on the pointer position instead of being always derived from the value in MUI Base (which is always rounded/clamped) 🙇 |
@SimeonRolev If you would like to test the fix locally in the mean time: npm install https://pkg.csb.dev/mui/base-ui/commit/6599a23d/@base-ui-components/react |
Bug report
Current behavior
Drag a
Slider
to one of its ends. Value is properly set to 0 or 100, but theSlider.Thumb
doesn't get positioned at the very start/end of theSlider.Track
(itsinset-inline-start
CSS property is set to 0.4242% or 99.4242%, for example). A proper positioning is only achievable with a quick drag. It's more obvious with wider sliders or multiple sliders one under the other.Screencast.from.27.01.2025.19.06.21.webm
Expected behavior
The positioning of the thumb should reflect the value passed to the
onValueChange(value, event)
- a value of0 / 100
positions theSlider.Thumb
atinset-inline-start: 0% / 100%;
without the need of a quick mouse drag.Reproducible example
https://base-ui.com/react/components/slider
Base UI version
^1.0.0-alpha.5
Which browser are you using?
Chrome
The text was updated successfully, but these errors were encountered: