juba / shinyglide

Glide.js component for Shiny apps
https://juba.github.io/shinyglide/
91 stars 8 forks source link

Conflict with shinyBS modal #34

Closed ShinyFabio closed 1 year ago

ShinyFabio commented 1 year ago

Hi, I've found a problem using the bsModal() from the shinyBS package. Basically bsModals can be used but the code for the modal must stay outside the glide() function. Here's a reproducible example:

library(shiny)
library(shinyglide)
library(shinyBS)
ui <- fixedPage(
  h3("Simple shinyglide app"),
  glide(
    screen(
      p("First screen."),
      actionButton("gomodal", "go"),
      shinyBS::bsModal("modal1", "ok", trigger = "gomodal",
                       p("here is the modal"))

    ),
    screen(
      p("Second screen.")
    )
  )
)

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

shinyApp(ui, server)

And here's a working example where I moved bsModaloutside the glide function:

library(shiny)
library(shinyglide)
library(shinyBS)
ui <- fixedPage(
  h3("Simple shinyglide app"),
  glide(
    screen(
      p("First screen."),
      actionButton("gomodal", "go")

    ),
    screen(
      p("Second screen.")
    )
  ),

  shinyBS::bsModal("modal1", "ok", trigger = "gomodal",
                   p("here is the modal"))

)

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

shinyApp(ui, server)

I tried to render the bsmodal inside a renderUI() function but the problem still persists if I put the uiOutput inside the glide function. It seems a minor problem (I can just move the bsmodal outside glide) but that's true for small modals. I use DataEditR package that uses a shinymodule with many options. The problem is that the ui part of the shinymodule contains both the trigger button and the bsModal and so can't be outside the glide function.

juba commented 1 year ago

Sorry for my late answer. I can reproduce the problem, bsModal should not be placed inside glide() otherwise the modal HTML is inserted inside the glide div instead of the root div, and styling and display is not right anymore.

Unfortunately I don't see what I could do about it, I cannot really work on complex CSS rules to handle this particular use case (plus shinyBS doesn't really seem to be developed anymore ?)...

ShinyFabio commented 1 year ago

Ok it's not a big issue. The only problem could be the readability of the code. However could be useful for others! Maybe you can highlight this minor issue somewhere (like in the description).