Open srtg4we5gsetrgwhreyt opened 6 years ago
The example from above:
library(shiny)
ui <- fluidPage(mainPanel(
sliderInput("lenval1", "Length #1:", min = 0.5, max = 24, value = 3 , step = 0.5),
checkboxInput("checkboxin","Toggle Step Size")
)
)
server <- function(input, output, session) {
observeEvent(input$checkboxin,{
if (isTRUE(input$checkboxin)) {
updateSliderInput(session, "lenval1", label = NULL, value=NULL,min = NULL, max = NULL, step = 1)
}
else {
updateSliderInput(session, "lenval1", label = NULL, value=NULL,min = NULL, max = NULL, step = 0.5)
}
})
}
shinyApp(ui = ui, server = server)
Investigate-only for v1.2
This seems to have nothing to do with updating, and everything to do with the min, max, and step sizes. Here's a minimal repro:
library(shiny)
ui <- fluidPage(
sliderInput("lenval1", "Length #1:", min = 0.5, max = 24, value = 3 , step = 1)
)
server <- function(input, output, session) {
}
shinyApp(ui = ui, server = server)
I was not surprised that something weird happens with min = 0.5, max = 24, step = 1, as max == min + x * step
isn't true for any integral value of x
. But I was surprised to find that if min = 0.5, max = 24.5, step = 1, then the slider will let you select any value in c(0.5, 2:24, 24.5)
--it doesn't snap to the 0.5
values which is slightly surprising to me, and skips 1
which is even more surprising.
@shalutiwari @alandipert @schloerke I'm dropping this from v1.2, this could be bundled into other slider improvement work though.
Looks like an issue with ion.rangeSlider: http://jsfiddle.net/winstonchang/36e4akxj/
Adding to this thread, in reference to a question asked on SO [here].(https://stackoverflow.com/questions/53197208/r-shiny-sliderinput-shows-repeated-values)
In this example we are using updateSelectInput
and inputting an expression into the max argument, this is causing the steps to repeat, and the slider to be, what I am guessing, stuck on the previous steps. I am not sure if this is b/c you are not supposed to pass expressions to this function, or if it is part of this bug
library(shiny)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
sliderInput(inputId="numberOfElements",
label = "Number of elements to delete",
#values updated dynamically on server.r
min = 1,
max = 5, value = 1, step = 1),
actionButton("button","Create Bug")
),
mainPanel(
)))
server <- function(input, output,session) {
observeEvent(input$button,{
updateSliderInput(session,
"numberOfElements",
min=1,
max = 5-1,
value = 0,
step=1)
})
}
shinyApp(ui = ui, server = server)
EDIT: This issue is also present w/o an expression, e.g. max=4 in the updateSelectInput
@EthanStevensUSGS This seems like a different, and worse, issue. It looks to me like the tick marks don't change, nor the number or position of the tick labels; the tick labels are just updated to round numbers. Try changing max
to various numbers; the numbers are almost but not quite right.
@EthanStevensUSGS I opened a separate issue #2254. Thanks for the report.
app.txt
For the attached app (change .txt to .R to run) there is an issue when I try to update a sliders step size from 0.5 to 1 using the updateSliderInput command, it seems to not be able to get the slider back to the original value.
Steps to reproduce issue: