react-input-range icon indicating copy to clipboard operation
react-input-range copied to clipboard

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

Open hemant63821 opened this issue 6 years ago • 3 comments

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)} />

hemant63821 avatar Aug 23 '19 06:08 hemant63821

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

jasonejavier avatar Aug 29 '19 02:08 jasonejavier

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.

vivrathore avatar Jan 26 '20 19:01 vivrathore

          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;

robba86 avatar Jun 27 '20 11:06 robba86