dashR icon indicating copy to clipboard operation
dashR copied to clipboard

Errors when the `mark` property of dccSlider when hot-reloading is active

Open firasm opened this issue 5 years ago • 3 comments

A couple of my students found either a bug in DashR, or a mistake in the documentation.

From this page, the slider component is written as:

      dccSlider(
        min = 0,
        max = 9,
        marks = c("", "Label 1", 2:5),
        value = 5
      )

This works fine when we don't have hot-reloading turned on (i.e. when run as app$run_server()) however when we turn it on (i.e. app$run_server(debug=TRUE)) we get this error message:

Invalid argument `marks` passed into Slider.
Expected an object.
Was supplied type `array`.
Value provided: 
[
  "",
  "Label 1",
  "2",
  "3",
  "4",
  "5"
]

I also tried another example here:

library(dashCoreComponents)
dccSlider(
  min = 0,
  max = 9,
  marks = lapply(1:10, function(x){paste("Label", x)}),
  value = 5,
)

and got a similar error.

Again, just to reiterate, things work fine with debug=FALSE and the error messages popup when debug=TRUE.

Could you advise what you think the issue is here?

This might have been previously reported here.

firasm avatar Mar 21 '20 07:03 firasm

P.S. this code works as expected:

library(dashCoreComponents)
dccSlider(
    min=0,
    max=10,
    marks = list(
    "0" = "0 °F",
    "3" = "3 °F",
    "5" = "5 °F",
    "7.65" = "7.65 °F",
    "10" = "10 °F"
    ),
    value=5
  )

And the dccSlider docs say:

If slider marks are defined and step is set to NULL then the slider will only be able to select values that have been predefined by the marks. marks is a list where the keys represent the numerical values and the values represent their labels.

firasm avatar Mar 21 '20 07:03 firasm

I am having this same issue on dash 0.5.0. I can update the docs dashr is intended to work this way, but I suspect this is a bug with debugger enabled? (although the docstring seem more consistent with the current behavior as noted above)

joelostblom avatar Jan 24 '21 04:01 joelostblom

I am having this same issue on dash 0.5.0. I can update the docs dashr is intended to work this way, but I suspect this is a bug with debugger enabled? (although the docstring seem more consistent with the current behavior as noted above)

Thanks for the report @joelostblom -- it's interesting to see this difference in behaviour when debug=TRUE vs debug=FALSE. For the moment, it wouldn't hurt to update the docs, though; if you're able to open a PR that would be great! I'm happy to review.

It looks like the spots requiring these updates are here and potentially here.

rpkyle avatar Jan 25 '21 16:01 rpkyle