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

Range Doesn't Support Custom Tooltip #377

Closed
lgants opened this issue Dec 7, 2017 · 7 comments
Closed

Range Doesn't Support Custom Tooltip #377

lgants opened this issue Dec 7, 2017 · 7 comments

Comments

@lgants
Copy link

lgants commented Dec 7, 2017

I copied the example in the docs and added a Range component that uses the same tooltip as the Slider. The custom tooltip on Slider works as anticipated. However, the tooltip on both Range components is identical despite one of the Range components receiving a handle prop with custom tooltip. Thoughts?

import 'rc-slider/assets/index.css';
import 'rc-tooltip/assets/bootstrap.css';
import React from 'react';
import Tooltip from 'rc-tooltip';
import Slider from 'rc-slider';

const createSliderWithTooltip = Slider.createSliderWithTooltip;
const Range = createSliderWithTooltip(Slider.Range);
const Handle = Slider.Handle;

const handle = (props) => {
  const { value, dragging, index, ...restProps } = props;
  return (
    <Tooltip
      prefixCls="rc-slider-tooltip"
      overlay={value}
      visible={true}
      placement="top"
      key={index}
    >
      <Handle value={value} {...restProps} />
    </Tooltip>
  );
};

const wrapperStyle = { width: 400, margin: 50 };

export default () => {
    return (
        <div>
            <div style={wrapperStyle}>
                <p>Slider with custom handle</p>
                <Slider min={0} max={20} defaultValue={3} handle={handle} />
            </div>
            <div style={wrapperStyle}>
                <p>Range with custom handle</p>
                <Range min={0} max={20} defaultValue={[3, 10]} handle={handle} />
            </div>
            <div style={wrapperStyle}>
                <p>Range with custom handle</p>
                <Range min={0} max={20} defaultValue={[3, 10]} tipFormatter={value => `${value}%`} />
            </div>
      </div>
    )
}
@aranair
Copy link

aranair commented Jan 11, 2018

I have a custom tooltip that is working for me (on a range). You can try importing Range instead?

import Slider, { Range } from 'rc-slider';

@hurrtz
Copy link

hurrtz commented Jan 17, 2018

Have you tried logging anything in your handle function to ensure that the function gets used? In my case the prop "handle" does not get triggered if the range is used as a createSliderWithTooltip(range). Guess, this is a bug... Theoretically you could work around this via the prop "handleStyle" and supply an array with objects containing css definitions, one object per handle, but there, also, is a bug where only the first object is being used and applied over all handles. Sorry for all the bad news, though.

@aranair
Copy link

aranair commented Jan 17, 2018

Hmm, I’m 100% certain it’s working for me because of a bunch of custom date formatting in it.

@bcvazquez
Copy link

If you want to use a custom Tooltip then you don't need to use createSliderWithTooltip, because that will override what you are trying to do. Just use Slider.Range as your Component rather than const Range = createSliderWithTooltip(Slider.Range);

@yesmeck
Copy link
Member

yesmeck commented Mar 8, 2018

Duplicate of #400

@yesmeck yesmeck closed this as completed Mar 8, 2018
@yesmeck yesmeck marked this as a duplicate of #400 Mar 8, 2018
@rainitesh
Copy link

is this working? For me, the tooltips don't show at all :(

@ZiedHf
Copy link

ZiedHf commented Mar 6, 2019

@rainitesh same problem for me. I tried the same example in the docs.
Tested on Chrome and Firefox.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants