Skip to content
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 tooltip not tracking with handle #648

Open
orro3790 opened this issue May 6, 2020 · 2 comments
Open

slider tooltip not tracking with handle #648

orro3790 opened this issue May 6, 2020 · 2 comments

Comments

@orro3790
Copy link

@orro3790 orro3790 commented May 6, 2020

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.

@stefanue
Copy link

@stefanue stefanue commented May 7, 2020

+1

@stefanue
Copy link

@stefanue stefanue commented May 7, 2020

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%);
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.