shinyFeedback
shinyFeedback copied to clipboard
resetLoadingButton interferes with shinyjs functions
I've noticed that resetLoadingButton
interferes with shinyjs
functionalities in two ways:
- button is hidden with
shinyjs::hide
->resetLoadingButton
shows it, - button is disabled with
shinyjs::disable
->resetLoadingButton
enables it. This behaviour is somehow by definition, but anyway could be confusing, because such a button still hasdisabled
class and looks like disabled, but really it isn't.
This simple app demonstrates the problem.
library(shiny)
shinyApp(
ui = basicPage(
shinyjs::useShinyjs(),
shinyFeedback::useShinyFeedback(),
actionButton("toggle", "Show/hide button"),
actionButton("togglestate", "Enable/disable button"),
actionButton("reset", "Reset button"),
shinyFeedback::loadingButton("button", "Loading button")
),
server = function(input, output, session) {
observeEvent(input$toggle, shinyjs::toggle("button"))
observeEvent(input$togglestate, shinyjs::toggleState("button"))
observeEvent(input$reset, shinyFeedback::resetLoadingButton("button"))
}
)
The first behaviour is caused by resetLoadingButton
restoring the initial style
completely and hence dropping display: none
, while the other by removing disabled
attribute.
Both issues could probably be tackled in different way (at least in my case they could). However maybe it is possible to account for this, for example by performing reset only if a button is really in "loading" state (another attribute?), with an option to force hard reset? Hidden state could also be maintained by keeping style definition.