shiny
shiny copied to clipboard
Output of ModuleServer doesn't always update using numericInput
System details
Browser Version: Firefox 124.0.1 (64 bit)
Output of sessionInfo():
R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22621)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C LC_TIME=English_United States.utf8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] devtools_2.4.5 usethis_2.1.6
loaded via a namespace (and not attached):
[1] Rcpp_1.0.10 rstudioapi_0.14 magrittr_2.0.3 pkgload_1.3.2 xtable_1.8-4 R6_2.5.1 rlang_1.0.6
[8] fastmap_1.1.1 urlchecker_1.0.1 stringr_1.5.0 tools_4.2.2 pkgbuild_1.4.0 sessioninfo_1.2.2 miniUI_0.1.1.1
[15] cli_3.6.0 remotes_2.4.2 htmltools_0.5.4 ellipsis_0.3.2 digest_0.6.31 lifecycle_1.0.3 crayon_1.5.2
[22] processx_3.8.0 shiny_1.8.1 purrr_1.0.1 callr_3.7.3 later_1.3.0 htmlwidgets_1.6.1 profvis_0.3.7
[29] vctrs_0.5.2 fs_1.6.0 promises_1.2.0.1 ps_1.7.2 memoise_2.0.1 glue_1.6.2 cachem_1.0.6
[36] mime_0.12 stringi_1.7.12 compiler_4.2.2 prettyunits_1.1.1 httpuv_1.6.8
Example application or steps to reproduce the problem
inputModuleUI <- function(id) {
numericInput(NS(id, "amount"), "amount", 10, min = 1, step = 1)
}
inputModuleServer <- function(id, data, filter = is.numeric) {
moduleServer(id, function(input, output, session) {
reactive(input$amount)
})
}
testApp <- function() {
ui <- fluidPage(
inputModuleUI("mod-1"),
verbatimTextOutput("myOutput"),
actionButton("action","refresh")
)
server <- function(input, output, session) {
output$myOutput <- renderPrint({
input$action
server_output <- inputModuleServer("mod-1")
server_output()
})
}
shinyApp(ui, server)
}
Describe the problem in detail
I'm amoduleServer to return the value from a numericInput in the matching UI module. This UI is called by the main ui of the app, and displayed via a verbatimTextOutput.
This works initially but the output can become stuck when adjusting the amount via the arrow tools. I've attached a short video which demonstrates this problem. Notice how when the number 28 is reached the output no longer updates until the refresh button is pressed. This happens again later when I reach the number 25.
https://github.com/rstudio/shiny/assets/2994053/a501f2da-936b-478b-8ce0-c1132374c517