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

Input range is taking in negative even after a positive value is being assigned as minValue #158

Open
hemant63821 opened this issue Aug 23, 2019 · 3 comments

Comments

@hemant63821
Copy link

Even after setting min value for the react input range the slider is accepting negative value, below is the code and the attachment necessary for the issue.
Screenshot 2019-08-23 at 12 15 22 PM
Screenshot 2019-08-23 at 12 15 50 PM

this.state = {
value: { min: 8000, max: 75000 }
}

<InputRange
formatLabel={value => ${this.convertToIndianFormat(value)}kms}
maxValue={100000}
minValue={0}
ref="input_range"
value={this.state.value}
onChange={value => this.setState({ value })}
onChangeComplete={value => this.bindDistanceRange(value.min, value.max, this.cityName, this.sortObject, this.searchText)}
/>

@jasonejavier
Copy link

Hi. I'm facing also the same issue. It happens when I double-click slider.
Capture

@vivrathore
Copy link

vivrathore commented Jan 26, 2020

This issue is caused when we click on the minimum range near starting. It is something random either on a single or double click. It might be an issue with the core code.

For now, the patch we can apply is via onChange function.

Make it

onChange={value => {
              console.log(value.min ); // This is just to show you when you get the minus value on click
              value.min = value.min <= 0 ? 10 : value.min;
              this.setState({ value })}
            } 

I am assuming your minimum value is 10 here because it is mine. Just replace 10 with your minimum value. This is not pure function but you get the logic here.

@robba86
Copy link

robba86 commented Jun 27, 2020

          value.min = value.min <= 0 ? 10 : value.min;

When i added this, or it was like this before (idk). The max value acts the same way, to fix:
value.max = value.max >= 100 ? 100 : value.max;

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

4 participants