From 28e08afdd4d3e84f98a23451e1ddd0e3e43b7eb2 Mon Sep 17 00:00:00 2001 From: vedhav Date: Thu, 10 Oct 2024 18:56:32 +0530 Subject: [PATCH] fix: make the slider work + fix recursive auto update --- R/toggleable_slider.R | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/R/toggleable_slider.R b/R/toggleable_slider.R index c86266b6..83d3f5dc 100644 --- a/R/toggleable_slider.R +++ b/R/toggleable_slider.R @@ -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) @@ -254,11 +255,11 @@ 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, ... @@ -266,10 +267,9 @@ toggle_slider_server <- function(id, is_dichotomous_slider = TRUE, 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,