I'm looking for a way to stop update*Input
functions from invalidating reactive values in my Shiny app. I want the update function to change only the visual UI component, not the underlying reactive value.
Here's a reprex:
library(shiny)
ui <- fluidPage(
sliderInput("slide1", "Slider", min = 0, max = 10, value = 5),
sliderInput("slide2", "Slider2", min = 0, max = 10, value = 0),
textOutput("slide2_val")
)
server <- function(input, output, session) {
observe({
updateSliderInput(session, "slide2", value = input$slide1)
}) |>
bindEvent(input$slide1)
output$slide2_val <- renderText({
paste("Value of `slide2`:", input$slide2)
})
}
shinyApp(ui, server)
The desired behaviour is for the value of input$slide2
to only change when the user interacts with slide2, but for the slider UI element to change when either slide1 or slide2 are interacted with.
Importantly, this needs to work for a variety of input*
functions. Listening for click events won't work for inputs like selectInput
(see my related issue).