daattali / shinycssloaders

⌛ Add loading animations to a Shiny output while it's recalculating
https://daattali.com/shiny/shinycssloaders-demo/
Other
395 stars 45 forks source link

"ui_element must be a Shiny tag" error when using plotlyOutput and DTOutput #73

Closed ilaria-kode closed 1 year ago

ilaria-kode commented 1 year ago

Hi,

when using the latest version on github ( 26a6569bfcddce9ce7821db1caa1b945aa4b3ffe ) , I get this error

ui_element must be a Shiny tag

on apps that were working fine with previous versions of the package and that use plotly or DT packages.

A minimal reprex is this app:

library(shiny)
library(shinycssloaders)
library(plotly)

ui <- fluidPage(

    sidebarLayout(
        sidebarPanel(

        ),

        mainPanel(
           plotlyOutput("distPlot") %>% withSpinner()
        )
    )
)

server <- function(input, output) {

    output$distPlot <- renderPlotly({

      faithful %>%
        ggplot(aes(eruptions,waiting))+
        geom_point()
    })
}

# Run the application
shinyApp(ui = ui, server = server)

I believe the problem is caused by the fact that the withSpinner function is checking for inheritance on shiny.tag while both plotlyOutput and DTOutput return objects with class shiny.tag.list .

thank you, Ilaria

daattali commented 1 year ago

Thanks for reporting and for doing the extra work of finding the cause!