JohnCoene / waiter

🕰️ Loading screens for Shiny
https://waiter.john-coene.com/
Other
495 stars 25 forks source link

Waiter not covering Leaflet widgets entirely #143

Closed JsLth closed 5 months ago

JsLth commented 11 months ago

When using a waiter on a Leaflet widget, the waiter element seems to cover only parts of the map. I'm using the newest version 0.2.5. This might be related to #126, but I'm not sure. Here's a reprex:

library(waiter)
library(shiny)
library(leaflet)

ui <- fluidPage(
  use_waiter(),
  leafletOutput("map", 400),
  actionButton("reload", "Reload map")
)

server <- function(input, output, session) {
  waiter <- Waiter$new(
    id = "map",
    html = tagList(spin_pulse(), h4("Loading map..."))
  )

  output$map <- renderLeaflet({
    waiter$show()
    on.exit(waiter$hide())
    Sys.sleep(3)
    leaflet(data = breweries91) %>%
      addMarkers()
  }) %>%
    bindEvent(input$reload, ignoreNULL = FALSE)
}

runApp(shinyApp(ui, server))

This issue seems to be different in different circumstances. Here is what I noticed:

  1. When initializing the map, the waiter seems to cover the entire map widget (see screenshot 1)
  2. When re-rendering the map, the waiter leaves a gap on the left side of the map widget (see screenshot 2)
  3. When inside a bs4Dash::box the waiter leaves a gap at the top of the map widget (see screenshot 2 and the code box below)

image When initializing the map, everything looks fine.

image When re-rendering, the waiter shows a gap on the left side.

image When rendering in a bs4Dash::box, the gap is wider and also shows at the top. Here's the code for the UI:

library(bs4Dash)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(
    sidebarMenu(
      menuItem(text = "map", tabName = "mapTab")
    )
  ),
  dashboardBody(
    use_waiter(),
    tabItem(
      tabName = "mapTab",
      box(
       leafletOutput("map"),
        actionButton("reload", "Reload map")
      )
    )
  )
)
JohnCoene commented 11 months ago

Thank for the detailed bug report and reproducible example, I will take a look at that as soon as I have the time!

JohnCoene commented 5 months ago

Took me long enough, apologies, just pushed a fix.

Thanks again for reporting this.