Skip to content

Commit

Permalink
fix: make the slider work + fix recursive auto update
Browse files Browse the repository at this point in the history
  • Loading branch information
vedhav committed Oct 10, 2024
1 parent f66482e commit 28e08af
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions R/toggleable_slider.R
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ toggle_slider_server <- function(id, is_dichotomous_slider = TRUE, step_slider =
})

output$slider_ui <- renderUI({
state <- slider_states()
req(input$toggle >= 0)
state <- isolate(slider_states())
if (length(seq(state$slider_min, state$slider_max)) < 10) {
# The values should be index reference instead of actual values because of how we are calling the `sliderInput`
ticks <- seq(state$slider_min, state$slider_max)
Expand All @@ -254,22 +255,21 @@ toggle_slider_server <- function(id, is_dichotomous_slider = TRUE, step_slider =
which(ticks == state$high_value) - 1
)
args <- list(
inputId = "slider",
inputId = session$ns("slider"),
label = NULL,
min = state$slider_min,
max = state$slider_max,
value = values,
value = c(state$low_value, state$high_value),
ticks = ticks,
step = step_slider,
...
)
ticks <- paste0(args$ticks, collapse = ",")
args$ticks <- TRUE
html <- suppressWarnings(do.call("sliderInput", args))
html$children[[2]]$attribs[["data-values"]] <- ticks
} else {
args <- list(
inputId = "slider",
inputId = session$ns("slider"),
label = NULL,
min = state$slider_min,
max = state$slider_max,
Expand Down

0 comments on commit 28e08af

Please sign in to comment.