plotly / dash-daq

Control components for Dash
MIT License
141 stars 40 forks source link

Dash Daq slider defaults to the negative minimum value when value is set to 0. [Bug] #102

Closed mithi closed 3 years ago

mithi commented 4 years ago

I do something like this:

dash_daq.Slider( 
    id=name,
    min=-120,
    max=120,
    value=0,
    size=150,
    updatemode=UPDATE_MODE,
    handleLabel={"showCurrentValue": True,"label": angle},
    step=5,
  )

And my slider defaults to -120 which is the default minimum value instead of the correct value 0. When I use a value=10 my slider defaults correctly to 10 as expected. It seems like this bug only happens when the default value is 0

The version I'm using is Dash DAQ '0.4.0'

I'm using dash in my project here

Thanks!

alexcjohnson commented 4 years ago

Good catch @mithi! Looks like we fail to distinguish undefined from 0 in several places, at least:

https://github.com/plotly/dash-daq/blob/42111db5c1c07584d4dec41cf1f462e17adc91d5/src/fragments/Slider.react.js#L69

(that's probably the most important one)

https://github.com/plotly/dash-daq/blob/42111db5c1c07584d4dec41cf1f462e17adc91d5/src/fragments/Slider.react.js#L96

(that looks like an edge case, but should also be addressed)

mithi commented 4 years ago

@alexcjohnson , Thanks for taking the time to read and investigate this issue!