The app below contains an actionButton, a shinyWidgets::progressBar and a selectInput:
When the Start button is clicked, an observeEvent is triggered in which I loop through the numbers 1-10 and increment the progress bar at each iteration. I would also like to update the value of the selectInput at each iteration but updateSelectInput does not work as expected. Instead of updating in tandem with the progress bar, the selectInput value is only updated once the loop has terminated. I don't understand why updateProgressBar works here but updateSelectInput doesn't?
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
actionButton(inputId = "go", label = "Start"), #, onclick = "$('#my-modal').modal().focus();"
shinyWidgets::progressBar(id = "pb", value = 0, display_pct = TRUE),
selectInput('letters', 'choose', letters)
)
server <- function(input, output, session) {
observeEvent(input$go, {
shinyWidgets::updateProgressBar(session = session, id = "pb", value = 0) # reinitialize to 0 if you run the calculation several times
for (i in 1:10) {
updateProgressBar(session = session, id = "pb", value = 100/10*i)
updateSelectInput(session, 'letters', selected = letters[i])
Sys.sleep(.5)
}
})
}
shinyApp(ui = ui, server = server)

withProgressandincProgress(see here) but it doesn't work either. But in fact I'm wondering: why would you wantselectInputto update automatically if it stops at the letter "j" (since it is the tenth letter)?updateFooInputfunctions inside a for-loop (I tested radio buttons, text etc). As far as I can tell, the only internal difference is callingsession$sendInputMessage()vs callingsession$sendCustomMessage().sendInputMessage()inside a for-loop, and there may be some good advice there.withProgressbut it doesn't allow me to change the position of a specific prog bar. I know how to change position using CSS but I would have to use a class rule.shiny-notification {...}that would apply to all progress indicators in my app. I used aselectInputjust as a toy example. In the actual app, I am updating some text usingremoveUIandinsertUIbut the behaviour is the same.insertUIandremoveUI. These usesession$sendInsertUIandsession$onFlushedinternally but the behaviour is the same as theupdateSelectInput.