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

Multiple slider doesn't render start values #13

Open
brambow opened this issue Aug 28, 2019 · 5 comments
Open

Multiple slider doesn't render start values #13

brambow opened this issue Aug 28, 2019 · 5 comments

Comments

@brambow
Copy link

brambow commented Aug 28, 2019

Using v0.7.0

import React, { useState } from 'react';
import { Segment } from 'semantic-ui-react';
import { Slider } from 'react-semantic-ui-range';

const FilterSlider = () => {
  const [values, setValues] = useState([0, 5000]);
  const settings = {
    start: [0, 5000],
    min: 0,
    max: 5000,
    step: 1,
    onChange: array => {
      setValues(array);
    }
  };
  return (
    <Segment>
      <Slider multiple value={values} color="teal" settings={settings} />
    </Segment>
  );
};

export default FilterSlider;

Result on first render:
image

What I expect to see
image

@brambow
Copy link
Author

brambow commented Aug 29, 2019

Interestingly, when I attempted my actual use case, which was dynamically adding the slider based on a button click, it renders as expected:

image

@renato
Copy link

renato commented Jan 12, 2020

I was having the same issue, but testing a little further the it happened with non-multiple ranges too.

Apparently it happens when the Slider isn't visible on initialization. On my scenario it was inside a <Accordion/>, so if the inner panel isn't visible when the Slider is first rendered, the start values don't show up because this.inner.offsetWidth equals 0.

const position =
Math.round(ratio * this.inner.offsetWidth) +
trackLeft -
innerLeft -
this.state.offset;

I could try a PR but I don't know if @iozbeyli is still accepting them.

@TimMcCauley
Copy link

Greetings @renato - I am facing the same issue. Do you have a workaround at hand?

@renato
Copy link

renato commented Dec 6, 2021

Hey @TimMcCauley, I ended up using another slider component (rc-slider), so I don't have a workaround at hand, unfortunately.

@TimMcCauley
Copy link

Thank you @renato, I will check it out! Appreciated.

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

3 participants