ebailey78 / shinyBS

Twitter Bootstrap Components for Shiny
182 stars 47 forks source link

Change the way shinyBS adds resource path #138

Open ColinFay opened 3 years ago

ColinFay commented 3 years ago

Because of the way {shinyBS} adds its resources to {shiny}, it's impossible to build a package that wraps one of {shinyBS} functions.

https://github.com/ebailey78/shinyBS/blob/shinyBS3/R/misc.R#L1

For example, with the following dummy package : https://github.com/ColinFay/gloup

library(shiny)

ui <- function(request){
  tagList(
    fluidPage(
      h1("BsTest"),
      sliderInput(
        "bins",
        "Number of bins:",
        min = 1,
        max = 50,
        value = 30
      ),
      gloup::tp()
    )
  )

}

server <- function(input, output, session){

}

shinyApp(ui, server)

the tooltip won't show because {shinyBS} is not attached to the search path so the addResourcePath() is never called.

I would suggest using .onLoad instead, or switching for a resource attachment at the function level.

Thanks, Colin

gexijin commented 1 year ago

I solved this issue with the showModal function, native of shiny. There is no need for using shinyBS now.

#Add this to the UI script:
actionButton("some_button", "Settings")

# Add this to the server script:    
observeEvent(input$some_button, {
  shiny::showModal(
    shiny::modalDialog(
      size = "l",
      p("something")
    )
  )
})