slider tooltip not tracking with handle
I see this is a recurring bug, but has anyone found a work-around? When sliding the handle, the value updates properly but the tooltip remains static until mouse release, then clicking on the handle again brings the tooltip to mouse position.
+1
I solved this issue by creating my own tooltip:
const Handle = Slider.Handle;
const handle = (props) => {
const { value, dragging, index, ...restProps } = props;
return (
<Handle value={value} {...restProps}>
<div className="inner">
<div className={`wdc-tooltip${dragging ? ' active' : ''}`}>
<span className="wdc-tooltip-inner">{value}</span>
</div>
</div>
</Handle>
);
};
and rendering the component like this:
<Slider
step="10"
handle={handle}
/>
You will need to add some css to style it, and no need for using other components such as <Tooltip>
here's my scss:
.wdc-tooltip {
position: absolute;
top: 0;
left: 50%;
transform: translate(-50%, -100%);
z-index: 9999;
font-size: 10px;
line-height: 1.5;
opacity: 0.9;
user-select: none;
visibility: hidden;
opacity: 0;
transition: all ease-in-out 150ms;
&.active {
visibility: visible;
opacity: 1;
top: -10px;
}
span {
display: block;
text-align: center;
color: #fff;
text-decoration: none;
background-color: #373737;
border-radius: 5px;
box-shadow: 0 0 4px rgba(0, 0, 0, 0.17);
position: relative;
font-weight: bold;
user-select: none;
padding: 5px 10px;
&:after {
content: '';
position: absolute;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
border-width: 5px 5px 0;
border-top-color: #373737;
left: 50%;
bottom: 0;
transform: translate(-50%, 100%);
}
}
}
I solved this issue by creating my own tooltip:
const Handle = Slider.Handle;const handle = (props) => { const { value, dragging, index, ...restProps } = props; return ( <Handle value={value} {...restProps}> <div className="inner"> <div className={`wdc-tooltip${dragging ? ' active' : ''}`}> <span className="wdc-tooltip-inner">{value}</span> </div> </div> </Handle> ); };and rendering the component like this:
<Slider step="10" handle={handle} />You will need to add some css to style it, and no need for using other components such as
<Tooltip>here's my scss:
.wdc-tooltip { position: absolute; top: 0; left: 50%; transform: translate(-50%, -100%); z-index: 9999; font-size: 10px; line-height: 1.5; opacity: 0.9; user-select: none; visibility: hidden; opacity: 0; transition: all ease-in-out 150ms; &.active { visibility: visible; opacity: 1; top: -10px; } span { display: block; text-align: center; color: #fff; text-decoration: none; background-color: #373737; border-radius: 5px; box-shadow: 0 0 4px rgba(0, 0, 0, 0.17); position: relative; font-weight: bold; user-select: none; padding: 5px 10px; &:after { content: ''; position: absolute; width: 0; height: 0; border-color: transparent; border-style: solid; border-width: 5px 5px 0; border-top-color: #373737; left: 50%; bottom: 0; transform: translate(-50%, 100%); } } }
Property 'Handle' does not exist on type 'ForwardRefExoticComponent<SliderProps<number | number[]> & RefAttributes<SliderRef>>'. Maybe it worked with previous versions but with "rc-slider": "^10.6.2" it doesn't work. Does anyone know how to solve this problem with the latest version?