ebailey78 / shinyBS

Twitter Bootstrap Components for Shiny
182 stars 47 forks source link

Tooltip disappears after updating input #65

Open lproctor-github opened 8 years ago

lproctor-github commented 8 years ago

Adding a bsTooltip to a selectInput works well initially. However, the tooltip disappears after updating the selectInput on the server side. Adding a tooltip on the server side subsequent to the update does not help.

A minimal example is attached. The tooltip appears before clicking the "Update Values" button, but not after.

ui.R:

library(shiny) 
library(shinyBS)

shinyUI(fluidPage(
    # Application title
    titlePanel("Update Loses Tooltip"),

    # Sidebar with a slider input for number of bins
    sidebarLayout(
      sidebarPanel(
        selectInput("vals", label="Select Value", choices=c("None")),
        bsTooltip("vals", title="This is a tooltip.", placement="top"),
        actionButton("updateButton", "Update Values")
      ),
    mainPanel()
  )
))

server.R:

library(shiny)
library(shinyBS)

shinyServer(function(input, output, session) {

  observeEvent(input$updateButton, {
    updateSelectInput(session, "vals", choices=c("One", "Two", "Three"), selected="One")
    addTooltip(session, "vals", title="Updated tooltip", placement="top")
  })

})

R version 3.2.3 (2015-12-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] shinyBS_0.61 shiny_0.13.0

loaded via a namespace (and not attached): [1] R6_2.1.2 htmltools_0.3 tools_3.2.3 Rcpp_0.12.3 jsonlite_0.9.19 digest_0.6.9 xtable_1.8-2
[8] httpuv_1.3.3 mime_0.4

almeidaxan commented 7 years ago

Indeed, I'm facing the same problem.

The conditions are the same as @lproctor-github listed: tooltip disappearing after an update, and using addTooltip on the server (after the update) doesn't do anything.

R version 3.3.1 (2016-06-21) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: OS X 10.12.4 (Sierra)

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] bfast_1.5.9 strucchange_1.5-1 sandwich_2.3-4 zoo_1.7-14
[5] shinyjs_0.9 shinyBS_0.61 rPython_0.0-6 RJSONIO_1.3-0
[9] RColorBrewer_1.1-2 markdown_0.7.7 lubridate_1.6.0 leaflet_1.1.0
[13] knitr_1.15.1 ggmap_2.6.1 ggplot2_2.2.1 dplyr_0.5.0
[17] devtools_1.12.0 pacman_0.4.1 shiny_1.0.1

dylancis commented 6 years ago

I have the same issue with addPopover disappearing after updateSelectInput

SarenT commented 4 years ago

Seems to be limited to selectInput. Updating textInput doesn't seem to be a problem.

R version 3.6.3 (2020-02-29) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 18.04.4 LTS

Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale: [1] LC_CTYPE=de_AT.UTF-8 LC_NUMERIC=C LC_TIME=de_AT.UTF-8 LC_COLLATE=de_AT.UTF-8 LC_MONETARY=de_AT.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=de_AT.UTF-8 LC_NAME=de_AT.UTF-8 LC_ADDRESS=de_AT.UTF-8 LC_TELEPHONE=de_AT.UTF-8
[11] LC_MEASUREMENT=de_AT.UTF-8 LC_IDENTIFICATION=de_AT.UTF-8

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] janitor_2.0.1 pracma_2.2.9 ggdendro_0.1-20 gplots_3.0.3 purrr_0.3.3 rlang_0.4.5 tidyr_1.0.2 shinyBS_0.61
[9] smoother_1.1 TTR_0.23-6 colorspace_1.4-1 xlsx_0.6.3 svglite_1.2.3 DT_0.13.2 colourpicker_1.0 sortable_0.4.2
[17] sticky_0.5.6.1 udunits2_0.13 xml2_1.3.1 shiny_1.4.0.2 ggpubr_0.2.5 magrittr_1.5 RColorBrewer_1.1-2 stringr_1.4.0
[25] dplyr_0.8.5 ggplot2_3.3.1

loaded via a namespace (and not attached): [1] bitops_1.0-6 xts_0.12-0 lubridate_1.7.8 rprojroot_1.3-2 tools_3.6.3 backports_1.1.6 R6_2.4.1 KernSmooth_2.23-17 [9] withr_2.1.2 tidyselect_1.0.0 curl_4.3 compiler_3.6.3 cli_2.0.2 shinyjs_1.1 labeling_0.3 caTools_1.18.0
[17] scales_1.1.0 systemfonts_0.1.1 digest_0.6.25 rmarkdown_2.1 pkgconfig_2.0.3 htmltools_0.4.0 sourcetools_0.1.7 fastmap_1.0.1
[25] learnr_0.10.1 htmlwidgets_1.5.1 rstudioapi_0.11 farver_2.0.3 generics_0.0.2 zoo_1.8-7 jsonlite_1.6.1 crosstalk_1.1.0.1 [33] gtools_3.8.2 Rcpp_1.0.4.6 munsell_0.5.0 fansi_0.4.1 gdtools_0.2.2 lifecycle_0.2.0 stringi_1.4.6 yaml_2.2.1
[41] snakecase_0.11.0 MASS_7.3-51.6 grid_3.6.3 gdata_2.18.0 promises_1.1.0 crayon_1.3.4 miniUI_0.1.1.1 lattice_0.20-41
[49] xlsxjars_0.6.1 knitr_1.28 pillar_1.4.3 markdown_1.1 ggsignif_0.6.0 glue_1.4.0 evaluate_0.14 vctrs_0.2.4
[57] httpuv_1.5.2 gtable_0.3.0 assertthat_0.2.1 xfun_0.12 mime_0.9 xtable_1.8-4 later_1.0.0 tibble_3.0.0
[65] rJava_0.9-12 ellipsis_0.3.0

jianhaizhang commented 3 years ago

I have the same issue.

NicWir commented 2 years ago

Same issue here.

mickeykawai commented 1 year ago

I happened to find a weird way that partly works as below.. Weirdly however, updated tooltip (message "Updated tooltip2.") will be cyclically on and off when different selectInput value is selected, after updateButton Update Values is hit. I hope some experts will clarify and give us explanation and better solution...

library(shiny) 
library(shinyBS)

ui <- fluidPage(
    # Application title
    titlePanel("Update Loses Tooltip"),

    # Sidebar with a slider input for number of bins
    sidebarLayout(
        sidebarPanel(
            uiOutput("switchable_tooltip"), 

            bsTooltip("q_dummy", title = "This is a tooltip.", placement = "top"),
            # It's quite weird, but 
            #  1. This dummy bsTooltip is required. 
            #  2. Set id other than 'vals'. Id not present elsewhere is ok. Do not set id 'vals' here. It prohibits initial tooltips to show up... 
            #bsTooltip("vals", title = "This is a tooltip.", placement = "top"),
            # This does not work, as id "vals" is the id where we want to add tooltip..

            selectInput("vals", label = "Select Value", choices = c("None")),
            actionButton("updateButton", "Update Values")
        ),
        mainPanel()
    )
)

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

    observeEvent(input$updateButton, {
        updateSelectInput(session, "vals", choices = c("One", "Two", "Three"), selected = "One")
        #addTooltip(session, "vals", title = "Updated tooltip", placement = "top")
        # Still this does not work, so uiOutput("switchable_tooltip") is required. 
    })

    output$switchable_tooltip = renderUI({
        if (input$vals == "None") {
            addTooltip(session, "vals", title = "Init tooltip2.", placement = "top")
        }
        else {
            addTooltip(session, "vals", title = "Updated tooltip2.", placement = "top")
        }
    })

}

shinyApp(ui, server)

In addition, for further info, below I add other 2 similar cases that results in different behavior.

  1. Addition of bsTooltip("vals"... works, as far as output$switchable_tooltip keeps if clause (but the 2nd on-off cycle still happens):

library(shiny) library(shinyBS)

ui <- fluidPage(

Application title

titlePanel("Update Loses Tooltip"),

# Sidebar with a slider input for number of bins
sidebarLayout(
    sidebarPanel(
        uiOutput("switchable_tooltip"), 

        bsTooltip("q_dummy", title = "This is a tooltip.", placement = "top"),
        # It's quite weird, but 
        #  1. This dummy bsTooltip is required. 
        #  2. Set id other than 'vals'. Id not present elsewhere is ok. Do not set id 'vals' here. It prohibits initial tooltips to show up... 
        #bsTooltip("vals", title = "This is a tooltip.", placement = "top"),
        # This does not work, as id "vals" is the id is where we want to add tooltip..

        selectInput("vals", label = "Select Value", choices = c("None")),
        bsTooltip("vals", title = "This is a tooltip.", placement = "top"),

        actionButton("updateButton", "Update Values")
    ),
    mainPanel()
)

)

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

observeEvent(input$updateButton, {
    updateSelectInput(session, "vals", choices = c("One", "Two", "Three"), selected = "One")
    #addTooltip(session, "vals", title = "Updated tooltip", placement = "top")
    # Still this does not work, so uiOutput("switchable_tooltip") is required. 
})

output$switchable_tooltip = renderUI({
    if (input$vals == "None") {
        #addTooltip(session, "vals", title = "Init tooltip2.", placement = "top")
    }
    else {
        addTooltip(session, "vals", title = "Updated tooltip2.", placement = "top")
    }
    #addTooltip(session, "vals", title = "Updated tooltip2.", placement = "top")
})

}

shinyApp(ui, server)


2. Addition of `bsTooltip("vals"...`, and in addition, removal of `if` clause in `output$switchable_tooltip` do show up the initial tooltip "This is a tooltip.", but weirdly on-off cycle of "Updated tooltip2." will not occur after updateButton is hit.

library(shiny) library(shinyBS)

ui <- fluidPage(

Application title

titlePanel("Update Loses Tooltip"),

# Sidebar with a slider input for number of bins
sidebarLayout(
    sidebarPanel(
        uiOutput("switchable_tooltip"), 

        bsTooltip("q_dummy", title = "This is a tooltip.", placement = "top"),
        # It's quite weird, but 
        #  1. This dummy bsTooltip is required. 
        #  2. Set id other than 'vals'. Id not present elsewhere is ok. Do not set id 'vals' here. It prohibits initial tooltips to show up... 
        #bsTooltip("vals", title = "This is a tooltip.", placement = "top"),
        # This does not work, as id "vals" is the id is where we want to add tooltip..

        selectInput("vals", label = "Select Value", choices = c("None")),
        bsTooltip("vals", title = "This is a tooltip.", placement = "top"),

        actionButton("updateButton", "Update Values")
    ),
    mainPanel()
)

)

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

observeEvent(input$updateButton, {
    updateSelectInput(session, "vals", choices = c("One", "Two", "Three"), selected = "One")
    #addTooltip(session, "vals", title = "Updated tooltip", placement = "top")
    # Still this does not work, so uiOutput("switchable_tooltip") is required. 
})

output$switchable_tooltip = renderUI({
    # if (input$vals == "None") {
    #     #addTooltip(session, "vals", title = "Init tooltip2.", placement = "top")
    # }
    # else {
    #     addTooltip(session, "vals", title = "Updated tooltip2.", placement = "top")
    # }
    addTooltip(session, "vals", title = "Updated tooltip2.", placement = "top")
})

}

shinyApp(ui, server)

radhikesh commented 1 year ago

I was having same issue. The bsTooltip was disappearing after updating ui.

I used tippy::tippy_this to avoid this issue.