-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[Tooltip] Tooltip (as slider ValueLabel
) won't show up until I click the slider thumb
#31198
Comments
This issue has been fixed in #32321. For your information, here are Codesandboxes before and after. |
ValueLabel
) won't show up until I click the slider thumb
As far as I know, this is not a bug, it's a support question. The reproduction provided for the issue https://codesandbox.io/s/customizedslider-demo-material-ui-forked-vh93v2?file=/demo.tsx raise what is going wrong: The ref should be forwarded: interface AirbnbThumbComponentProps extends React.HTMLAttributes<unknown> {}
-function AirbnbThumbComponent(props: AirbnbThumbComponentProps) {
- const { children, ...other } = props;
- return (
- <SliderThumb {...other}>
- {children}
- <span className="airbnb-bar" />
- <span className="airbnb-bar" />
- <span className="airbnb-bar" />
- </SliderThumb>
- );
-}
+const AirbnbThumbComponent = React.forwardRef(
+ (props: AirbnbThumbComponentProps, ref) => {
+ const { children, ...other } = props;
+ return (
+ <SliderThumb {...other} ref={ref}>
+ {children}
+ <span className="airbnb-bar" />
+ <span className="airbnb-bar" />
+ <span className="airbnb-bar" />
+ </SliderThumb>
+ );
+ }
+);
export default function CustomizedSlider() {
return ( once the change is done, it now works correctly: https://codesandbox.io/s/customizedslider-demo-material-ui-forked-yn4d9n?file=/demo.tsx:1276-1296. I have reverted #32321 in b786ec4 as #32321 (comment) has no feedback after a week. |
Regarding the next step, I think that we have two possible opportunities to better solve the root problem:
|
+1 for doing this. |
Duplicates
Latest version
Current behavior 😯
When overriding ValueLabel in Slider props with a custom tooltip like this
we observed following behavior
Expected behavior 🤔
We should not have to click on the thumb to make tooltip work
Steps to reproduce 🕹
Steps:
components
propContext 🔦
No response
Your environment 🌎
`npx @mui/envinfo`
The text was updated successfully, but these errors were encountered: