shiny icon indicating copy to clipboard operation
shiny copied to clipboard

Allow to specify disconnect overlay template

Open dseynaev opened this issue 4 years ago • 6 comments

This PR adds an overridable <template> that, when present, is used to fill the grey-out div when it is generated.

This can be used to customize the content of the disconnect overlay (without the need for extra JS from the user).

This is a POC implementation of my suggestion in https://github.com/rstudio/shiny/issues/1828

The only downside is that this does not properly support IE (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template#browser_compatibility).

dseynaev avatar Apr 12 '21 16:04 dseynaev

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Apr 12 '21 16:04 CLAassistant

Can you provide an example of how the application author would use this?

wch avatar Apr 12 '21 17:04 wch

I've been using the following example for testing:

shiny::shinyApp(
    ui = function(request) {	
      shiny::tags$body(
          shiny::fluidPage(),
          shiny::tags$template(
              id = "shiny-disconnected-overlay-template",
              shiny::tags$div("some content")
          )
      )
    },
    server = function(input, output, session) {
      stop("something happened")
    }
)

dseynaev avatar Apr 12 '21 17:04 dseynaev

If I understand the code correctly, wouldn't this also work (without the call to body())?

shinyApp(
  ui = fluidPage(
    "Page content",
    tags$template(
      id = "shiny-disconnected-overlay-template",
      tags$div("some content")
    )
  ),
  server = function(input, output, session) {
    stop("something happened")
  }
)

And I don't think the changes in shinyui.R are needed.

wch avatar Apr 12 '21 19:04 wch

that would also work. I put the <template> under <body> to have it at the same level as the shiny-disconnected-overlay div (seemed to be the general practice, but the template spec is flexible enough), but this can be totally left to application author.

point taken about the changes to shinyui.R; removed them

dseynaev avatar Apr 12 '21 19:04 dseynaev

rebased to resolve conflicts

@wch anything else I can do from my side? ci was reporting a 403 trying to access my forked repo; not sure how to resolve that: it's public

dseynaev avatar Jun 07 '21 14:06 dseynaev