I already asked this at shiny, but as it turned out this was an issue of the modal, so I thought I'd ask here:
To replicate the error:
1) open modal via button
2) Look at the text Output and the slider/selectize values in the UI
While both the slider and selectize are updated to 5 in the UI, the input value for the slider is not updated. This only happens at the beginning. If the user changes the slider manually or uses the numericInput the input value is updated accordingly.
This error does not occur if you leave out the modal.
library(shiny)
library(shinyBS)
shinyApp(
ui = fluidPage(
mainPanel(
actionButton("modal", "open modal"),
shinyBS::bsModal(id = "row", trigger = "matrigg",
h2("Look at the text out put below before you change anything"),
textOutput("print"),
sliderInput("slider1", "my_slider", min = 1, max = 5, value = 1),
selectizeInput("selectize", "selectize", choices = 1:5, selected = 1),
numericInput("numinput", "Numbers", value = 5)
)
)
),
server = function(input, output, session) {
observeEvent({
input$modal
},{
# Error only happens when a modal is used
shinyBS::toggleModal(session, "row")
})
observeEvent({
input$numinput
},{
updateSliderInput(session, "slider1", max = input$numinput, value = input$numinput)
updateSelectizeInput(session, "selectize", choices = 1:input$numinput, selected = input$numinput)
})
output$print <- renderText({
paste0("Slider value: ", input$slider1,"\nSelectize value :", input$selectize)
})
}
)
I already asked this at shiny, but as it turned out this was an issue of the modal, so I thought I'd ask here:
To replicate the error: 1) open modal via button 2) Look at the text Output and the slider/selectize values in the UI
While both the slider and selectize are updated to 5 in the UI, the input value for the slider is not updated. This only happens at the beginning. If the user changes the slider manually or uses the numericInput the input value is updated accordingly.
This error does not occur if you leave out the modal.