JohnCoene / tippy

💬 Tippy.js for Shiny
http://tippy.john-coene.com/
Other
77 stars 2 forks source link

Tippy + reactive #10

Open tonihaag opened 3 years ago

tonihaag commented 3 years ago

In the newest package version, tippys are not reacting to changes in shiny inputs (specifically radio buttons) - I'm using tippyOutput and renderTippy ... they'll populate with data at the front end, but then as the inputs are changed which also changes a reactive, the tippy does not react

tonihaag commented 3 years ago

version 0.0.1 works just fine - but version 0.1.0 does not work

dmenne commented 3 years ago

To be able to update tippy text, I am looking for something like the mentioned tippyOutput or similar, but could not find the documentation.

lanceupton commented 2 years ago

I'm dealing with the same issue and have provided a MRE below to help solve this issue:

library(shiny)
library(tippy)

ui <- fluidPage(
  tags$br(),
  actionButton("btn", "update val"),
  tags$hr(),
  uiOutput("val_txt"),
  tags$br(),
  uiOutput("val_icon")
)

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

  # val is reactive source for tooltip text
  val <- reactive({
    input$btn
    sample(letters, 1)
  })

  # Tooltip over text - works fine with reactive tooltip text
  output$val_txt <- renderUI({
    tippy(
      text = "Text",
      tooltip = val(),
      placement = "right"
    )
  })

  # Tooltip over UI - doesn't work with reactive tooltip text
  output$val_icon <- renderUI({
    with_tippy(
      element = icon("question-circle"),
      tooltip = val(),
      placement = "right"
    )
  })

}

shinyApp(ui, server)

Expected result: When you click the update val button, the letter displayed in the tooltip text should update in each element. This works for the text element with the tooltip rendered via tippy, but does not work for the UI element (an icon) with the tooltip rendered via with_tippy.