shinyFeedback
shinyFeedback copied to clipboard
Value of loadingButton is not reset immediately on initialisation
When loadingButton
is recreated with the same ID, corresponding input
value is not reset until the button is clicked for the first time. This behaviour differs from the built-in actionButton
, where value is immediately set to 0. Simple demonstration, using the latest dev version, below.
I believe that loadingButton
should behave the same as actionButton
in this matter. loadingButton
initial value is null
, not 0
, but this is not important - what is important is that value should be reset to default immediately. Actually the fix should be as simple as calling Shiny.setInputValue
somewhere during the initialisation. I've already created PR with suggested change: https://github.com/merlinoa/shinyFeedback/pull/68, but I'm not sure whether it is the best place to do it.
library("shiny")
shinyApp(
ui = basicPage(
shinyFeedback::useShinyFeedback(),
actionButton("rerender", "Rerender buttons"),
uiOutput("buttons"),
wellPanel(
"actionButton",
verbatimTextOutput("b1_val"),
verbatimTextOutput("val1")
),
wellPanel(
"loadingButton",
verbatimTextOutput("b2_val"),
verbatimTextOutput("val2")
)
),
server = function(input, output, session) {
output$buttons <- renderUI({
input$rerender
tagList(
actionButton("b1", "actionButton"),
shinyFeedback::loadingButton("b2", "loadingbutton")
)
})
output$b1_val <- renderPrint(input$b1)
val1 <- eventReactive(input$b1, rnorm(1))
output$val1 <- renderPrint(val1())
output$b2_val <- renderPrint(input$b2)
val2 <- eventReactive(input$b2, {
shinyFeedback::resetLoadingButton("b2")
rnorm(1)
})
output$val2 <- renderPrint(val2())
}
)
- Session info ------------------------------------------------------------------------------
setting value
version R version 4.1.0 (2021-05-18)
os Windows 10 x64 (build 22621)
system x86_64, mingw32
ui RStudio
language (EN)
collate Polish_Poland.1250
ctype Polish_Poland.1250
tz Europe/Warsaw
date 2023-01-31
rstudio 2022.12.0+353 Elsbeth Geranium (desktop)
pandoc NA
- Packages ----------------------------------------------------------------------------------
package * version date (UTC) lib source
bslib 0.3.1 2021-10-06 [1] CRAN (R 4.1.2)
cachem 1.0.6 2021-08-19 [1] CRAN (R 4.1.2)
cli 3.1.0 2021-10-27 [1] CRAN (R 4.1.2)
digest 0.6.31 2022-12-11 [1] CRAN (R 4.1.3)
ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.1.2)
fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.1.2)
fontawesome 0.2.2 2021-07-02 [1] CRAN (R 4.1.2)
htmltools 0.5.4 2022-12-07 [1] CRAN (R 4.1.3)
httpuv 1.6.5 2022-01-05 [1] CRAN (R 4.1.2)
jquerylib 0.1.4 2021-04-26 [1] CRAN (R 4.1.2)
jsonlite 1.7.3 2022-01-17 [1] CRAN (R 4.1.2)
later 1.3.0 2021-08-18 [1] CRAN (R 4.1.2)
lifecycle 1.0.1 2021-09-24 [1] CRAN (R 4.1.2)
magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.1.2)
mime 0.12 2021-09-28 [1] CRAN (R 4.1.1)
promises 1.2.0.1 2021-02-11 [1] CRAN (R 4.1.2)
R6 2.5.1 2021-08-19 [1] CRAN (R 4.1.2)
Rcpp 1.0.8 2022-01-13 [1] CRAN (R 4.1.2)
rlang 1.0.6 2022-09-24 [1] CRAN (R 4.1.3)
rstudioapi 0.13 2020-11-12 [1] CRAN (R 4.1.2)
sass 0.4.0 2021-05-12 [1] CRAN (R 4.1.2)
sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.1.2)
shiny * 1.7.1 2021-10-02 [1] CRAN (R 4.1.2)
shinyFeedback 0.4.0.9001 2023-01-31 [1] Github (merlinoa/shinyFeedback@b741fed)
xtable 1.8-4 2019-04-21 [1] CRAN (R 4.1.2)