Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resetLoadingButton interferes with shinyjs functions #62

Open
bartekch opened this issue Feb 25, 2022 · 0 comments
Open

resetLoadingButton interferes with shinyjs functions #62

bartekch opened this issue Feb 25, 2022 · 0 comments

Comments

@bartekch
Copy link

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 has disabled 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant