slider icon indicating copy to clipboard operation
slider copied to clipboard

Issue with slider

Open JustStanix opened this issue 4 years ago • 3 comments

So I have a range slider with tooltips. My problem is that I use custom onChange and value.

<Range
    className="c-range"
    value={valueState}
    onChange={value => setValueState(value)}
    min={minPossible}
    max={maxPossible}
/>

If I just use Slider.Range without tooltips it works fine. But when I do:

const { createSliderWithTooltip } = Slider;
const Range = createSliderWithTooltip(Slider.Range);

And use Range like in the example above, the value only changes by 1 until I let go and click again.

JustStanix avatar Aug 26 '20 16:08 JustStanix

So I have a range slider with tooltips. My problem is that I use custom onChange and value.

<Range
    className="c-range"
    value={valueState}
    onChange={value => setValueState(value)}
    min={minPossible}
    max={maxPossible}
/>

If I just use Slider.Range without tooltips it works fine. But when I do:

const { createSliderWithTooltip } = Slider;
const Range = createSliderWithTooltip(Slider.Range);

And use Range like in the example above, the value only changes by 1 until I let go and click again.

This also happen with Slider...

huarmenta avatar Apr 27 '21 23:04 huarmenta

So I have a range slider with tooltips. My problem is that I use custom onChange and value.

<Range
    className="c-range"
    value={valueState}
    onChange={value => setValueState(value)}
    min={minPossible}
    max={maxPossible}
/>

If I just use Slider.Range without tooltips it works fine. But when I do:

const { createSliderWithTooltip } = Slider;
const Range = createSliderWithTooltip(Slider.Range);

And use Range like in the example above, the value only changes by 1 until I let go and click again.

Same here

murilopereirame avatar May 25 '21 22:05 murilopereirame

An workaround for this is, instead of update state in onChange, update in onAfterChange and instead of define value attribute, define the defaultValue, like this:

<Range 
    min={1} 
    max={500}
    step={1}
    draggableTrack={true}                         
    onAfterChange={(val1) => {
        setRDistance(val1);
    }}
    defaultValue={rangeDistance} />

murilopereirame avatar May 26 '21 20:05 murilopereirame