Giter VIP home page Giter VIP logo

Comments (7)

ebailey78 avatar ebailey78 commented on July 21, 2024

Thank you for the feedback. That's interesting. It looks like its a timing issue. bsTooltip is firing before shiny has had the chance to render the button. shinyBS waits 100ms to give shiny a chance to load everything but apparently that isn't enough time in this case. When you remove the collapses, shiny renders the button sooner and its there when bsTooltip fires. I increased the delay from 100ms to 500ms and that seems to be enough time to render the button with or without the collapses.

I think the better way to handle this may be to include bsTooltip as part of renderUI so in your server script you would have something like this:

  output$tooltip_test <- renderUI({
    tagList(
        actionButton("test", "Test"),
        bsTooltip("test", title = "Test", placement="right")
    )
  })

I tested that and it seems to work in your example. Let me know if it fixes the real problem you are having. Regardless, there should be a more intuitive way to add tooltips and popovers to rendered elements. I will see what I can do.

Thanks,

Eric

from shinybs.

jgabry avatar jgabry commented on July 21, 2024

Thanks! The increase from 100ms to 500ms definitely seems to help.

from shinybs.

ebailey78 avatar ebailey78 commented on July 21, 2024

I just added a new function tipify so you can wrap any other shiny element in tipify and it will create a tooltip on the wrapped element. I think this is a better solution than hoping that the timing works out right. So instead of bsTooltip in your UI, your server would look like this:

output$tooltip_test <- renderUI({
    tipify(actionButton("test", "Test"), title = "Test", placement = "right")
})

If you can, try it and see if it works for you. I think this would be a safer method for adding tooltips to elements created with renderUI.

from shinybs.

jgabry avatar jgabry commented on July 21, 2024

Cool. That seems like a good idea. It does work for me in the toy example, but I can't get it to work in my actual shiny app. Here's the relevant code from my server and ui files:

In server.R

output$ui_multiview_customize <- renderUI({
  bsCollapse(
    bsCollapsePanel(title = "View Options",
      checkboxInput("multiview_checkbox", label = "Include warmup", value = FALSE),
      hr(),
      tipify(downloadButton("download_multiview", "Save as ggplot2 objects"), 
         title = "Save ggplot2 object in .RData file.", placement="right")
    )
  )
})

and then in ui.R I have

tabPanel("Multiview", 
   uiOutput("ui_multiview_customize"),
   plotOutput("multiview_plot")
)

Everything works fine except the tooltip doesn't show up.

from shinybs.

ebailey78 avatar ebailey78 commented on July 21, 2024

I created this example to try to replicate your situation:

library(shiny)
library(shinyBS)

shinyApp(
  ui =
    fluidPage(
      tabsetPanel(
        tabPanel("Tab #1",
          plotOutput("genericPlot")
        ),
        tabPanel("Tab #2",
          uiOutput("ui_multiview_customize"),
          plotOutput("multiview_plot")
        )
      )
    ),  
  server =
    function(input, output, session) {
      output$genericPlot <- renderPlot(plot(rnorm(1000)))
      output$multiview_plot <- renderPlot(plot(runif(1000)))
      output$ui_multiview_customize <- renderUI({
        bsCollapse(
          bsCollapsePanel(title = "View Options",
                          checkboxInput("multiview_checkbox", label = "Include warmup", value = FALSE),
                          hr(),
                          tipify(downloadButton("download_multiview", "Save as ggplot2 objects"), 
                                 title = "Save ggplot2 object in .RData file.", placement="right")
          )
        )
      })
    }
)

And tipify works for me in this example. Am I missing something?

from shinybs.

jgabry avatar jgabry commented on July 21, 2024

Hmmm, tipify works for me too in this example, so I don't think you're missing anything.

It just doesn't work when this example is placed in the larger context of my app. There must be something else going on in my app that prevents it from working, but I'm not sure what it would be.

from shinybs.

stevepowell99 avatar stevepowell99 commented on July 21, 2024

aha, do these delay issues affect bsCollapse as well? I have an app in which the panels keep closing as soon as they have fully opened, I think because the app is taking rather long render its stuff. If so, is there an easy way to tweak the delay, I can't find it in the code.

from shinybs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.