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

Resetting dynamically rendered loadingButton fails #50

Closed
matthijsvanderloos opened this issue Oct 21, 2020 · 3 comments
Closed

Resetting dynamically rendered loadingButton fails #50

matthijsvanderloos opened this issue Oct 21, 2020 · 3 comments
Assignees

Comments

@matthijsvanderloos
Copy link

I have a Shiny app that uses shiny::renderUI() to dynamically render a shinyFeedback::loadingButton(). Despite the button being rendered correctly, calling shinyFeedback::resetLoadingButton() later on fails to actually reset the button.

From my analysis it seems the message handler for resetLoadingButton is attached in loadingButton.js (https://github.com/merlinoa/shinyFeedback/blob/master/inst/assets/js/loadingbutton.js#L77-L82) on the shiny:sessioninitialized event. I guess this event has already been triggered before the button is rendered (and loadingButton.js is loaded).

Reprex:

library(shiny)
library(shinyFeedback)


ui <- fluidPage(
  title = "Shinyfeedback loading button",
  fluidRow(
    column(width = 4,
      uiOutput("lb"),
      actionButton("stop_btn", "Stop searching")
    )
  )
)

server <- function(input, output, session) {
  output$lb <- renderUI({
      loadingButton("loadingbutton", label = "Search", loadingLabel = "Searching...")
      
  })
  
  observeEvent(input$stop_btn, {
    # The following does not reset the loading button
    resetLoadingButton("loadingbutton")    
  })
  
}

shinyApp(ui = ui, server = server)
@phoward38
Copy link
Collaborator

Hey @matthijsvanderloos,

Thanks for the informative issue & reprex! You're correct about the cause of the issue. We plan to have this fixed in the next minor CRAN release of shinyFeedback.

Feel free to make a PR if you need this addition ASAP. Otherwise, I'll update you on the fix as soon as it's added to the development version.

@merlinoa
Copy link
Owner

merlinoa commented Oct 21, 2020

Yes thanks very much @matthijsvanderloos. Excellent reprex and issue! I just pushed a fix to master. Please reopen if that did not resolve the issue.

@matthijsvanderloos
Copy link
Author

Hi @phoward38, @merlinoa,

Thanks for the quick response! I have tested the fix and it indeeds resolves the issue.

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

3 participants