Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tooltip not working with bookmarkButton? #318

Open
b-rodrigues opened this issue Oct 6, 2022 · 2 comments
Open

tooltip not working with bookmarkButton? #318

b-rodrigues opened this issue Oct 6, 2022 · 2 comments
Labels
incompatibility conflict with other package

Comments

@b-rodrigues
Copy link

b-rodrigues commented Oct 6, 2022

Hi

it seems that adding tooltips doesn’t work with bookmarkButton()’s? Here’s a MRE:

  library(shiny)
  library(bs4Dash)

  shinyApp(
    ui = dashboardPage(
      header = dashboardHeader(
        title = bs4DashBrand(
          title = "My dashboard",
        )
      ),
      sidebar = dashboardSidebar(),
      body = dashboardBody(
  tooltip(
        title = "Coucou",
          actionButton(
            "goButton", "Go!", 
            status = "danger", 
            outline = TRUE, 
            flat = TRUE, 
            size = "lg"
          ),
        ),
  tooltip(
    title = ":(",
    bookmarkButton(
      label = "Bookmark"
    ),
    )
      ),
      controlbar = dashboardControlbar(),
      title = "DashboardPage"
    ),
    server = function(input, output) {
    }
  )

@DivadNojnarg
Copy link
Member

Hi Bruno,

Screenshot 2022-10-12 at 14 57 04

I get a JS error in the console because of the wrong id format. I don't know why the bookmarkButton function code provides such id by default, given that any punctuation triggers a jQuery error (see here: https://unleash-shiny.rinterface.com/custom-templates-testing.html#avoid-wrong-jquery-selectors):

bookmarkButton <- function (label = "Bookmark...", icon = shiny::icon("link", lib = "glyphicon"), 
    title = "Bookmark this application's state and get a URL for sharing.", 
    ..., id = "._bookmark_") { ... }

So a workaround for you would be to pass an id. I would be curious to know the reason behind this default value for id on the Shiny side (poke @schloerke). That being said, here is a working code:

library(shiny)
library(bs4Dash)

enableBookmarking(store = "url")

shinyApp(
  ui = dashboardPage(
    header = dashboardHeader(
      title = bs4DashBrand(
        title = "My dashboard",
      )
    ),
    sidebar = dashboardSidebar(),
    body = dashboardBody(
      tooltip(
        title = "Coucou",
        actionButton(
          "goButton", "Go!", 
          status = "danger", 
          outline = TRUE, 
          flat = TRUE, 
          size = "lg"
        ),
      ),
      tooltip(
        title = ":(",
        bookmarkButton(
          label = "Bookmark", id = "bookmark"
        ),
      )
    ),
    controlbar = dashboardControlbar(),
    title = "DashboardPage"
  ),
  server = function(input, output, session) {
    observeEvent(input$bookmark, {
      session$doBookmark()
    })
  }
)

@DivadNojnarg DivadNojnarg added the incompatibility conflict with other package label Oct 12, 2022
@b-rodrigues
Copy link
Author

Hi @DivadNojnarg

many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incompatibility conflict with other package
Projects
None yet
Development

No branches or pull requests

2 participants