mui / material-ui

Material UI: Ready-to-use foundational React components, free forever. It includes Material UI, which implements Google's Material Design.
https://mui.com/material-ui/
MIT License
92.43k stars 31.84k forks source link

[Slider] Prevent dragging Slider knobs by it's labels #33359

Closed nikkizol closed 2 years ago

nikkizol commented 2 years ago

Duplicates

Latest version

Current behavior 😯

I have Slider which acceptsValueLabel component which is Tooltip. Tooltip is set to interactive={true} as I pass TextField to the title property. So when I hoover over the knob I want to have editable Tooltip.

The issue is that when I dragging by Tooltip, the slider also is dragging.

See video:

https://user-images.githubusercontent.com/45672257/176929951-47fda612-796e-4a87-b294-969e7f83d39f.mov

CodeSandBox - https://codesandbox.io/s/rangeslider-demo-material-ui-forked-fuif4l?file=/demo.tsx

Expected behavior 🤔

To no allow drag slider by dragging Tooltip.

Steps to reproduce 🕹

Steps:

  1. Create Slider component
  2. Pass ValueLabelComponent to ValueLabel which is Tooltip see an example in CodeSandBox - https://codesandbox.io/s/rangeslider-demo-material-ui-forked-fuif4l?file=/demo.tsx
  3. Set Tooltip interactive property to true
  4. Hover over the slider knob and drag by the Tooltip

Context 🔦

No response

Your environment 🌎

npx @mui/envinfo ``` Don't forget to mention which browser you used. Output from `npx @mui/envinfo` goes here. ```
michaldudak commented 2 years ago

Add onMouseDown={(e) => e.stopPropagation()} to the TextField inside the Tooltip to prevent users from dragging it. Would it resolve your issue?

nikkizol commented 2 years ago

@michaldudak Yes, thanks!