Skip to content

Popover title isn't getting removed after being added #1011

@cpsievert

Description

@cpsievert

Do the following in the following to repro the issue:

  1. Click "Show popover"
  2. Click "Hide popover"
  3. Click "Show popover"
  4. Switch on "Add a popover title"
  5. Switch off "Add a popover title"

Step 5 should remove the title from popover, but it doesn't. This issue was surfaced after a recent fix in #747 by an existing popover test https://rstudio.github.io/shinycoreci/results/2024/03/15/#316-bslib-popovers-macOS-4.3

library(shiny)
library(bslib)
library(plotly)

ui <- page_sidebar(
  title = "Popover tests",
  card(
    card_header(
        popover(
          span(
            "Card title with popover",
            bsicons::bs_icon("question-circle-fill")
          ),
          "Popover message",
          id = "popover",
          placement = "right"
        )
    ),
    plotlyOutput("bars")
  ),
  sidebar = list(
    textInput("popover_msg", "Enter a popover message", "Popover message"),
    actionButton("show_popover", "Show popover", class = "mb-3"),
    actionButton("hide_popover", "Hide popover"),
    br(),
    input_switch("show_title", "Add a popover title"),
    conditionalPanel(
      "input.show_title",
      textInput("popover_title", "Enter a title", "Popover title"),
    )
  )
)

server <- function(input, output, session) {
  observe({
    update_popover(
      "popover", input$popover_msg,
      title = if (input$show_title) input$popover_title
    )
  })

  observeEvent(input$show_popover, {
    toggle_popover("popover", show = TRUE)
  })

  observeEvent(input$hide_popover, {
    toggle_popover("popover", show = FALSE)
  })

  output$bars <- renderPlotly({
    plot_ly(diamonds, x = ~cut)
  })
}

shinyApp(ui, server)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions