Modal not working with Kable table

I am trying to configure a modal alert in a shiny app. In the modal I want to show a table . For this I am using kable extra and tableOuput in UI. But for some reason the modal wont open up when I use tableOuput. Below is the code which I using.

library(shiny)
library(shinyWidgets)
library(shinydashboard)
library(kableExtra)


sidebar <- dashboardSidebar(
  sidebarMenu(id = "tab",
              menuItem("1", tabName = "1"),
              menuItem("2", tabName = "2"),
              menuItem("3", tabName = "3"),
              menuItem("4", tabName = "4")
              
  )
)
body <-   ## Body content
  dashboardBody(box(width = 12,fluidRow(
    column(
      width = 3,
      pickerInput(
        inputId = "metric",
        label = h4("Metric Name"),
        choices = c(
          "alpha",
          "beta"
        ),
        
        width = "100%"
      ), actionButton(tableOutput("show"), "Help")
    )
  )))

ui <-   dashboardPage(dashboardHeader(title = "Scorecard"),
                      sidebar,
                      body)

# Define the server code
server <- function(input, output,session) {
  observeEvent(input$metric, {
    if (input$tab == "1"){
      choices <- c(
        "alpha",
        "beta"
      )
    }
    else if (input$tab == "2") {
      choices <- c(
        "apple",
        "orange"
      )
    }
    else {
      choices <- c(
        "foo",
        "zoo",
        "boo"
      )
    }
    updatePickerInput(session,
                      inputId = "metric",
                      choices = choices)
  })
  
    faq1 <- data.frame(
    Findings = c(
      "lorem ipsum"
    ))
    faq2 <- data.frame(
      Findings = c(
        "lorem ipsum bacon"
      ))
      
      faq3 <- data.frame(
        Findings = c(
          "lorem ipsum bacon bacon"
        ))
  
  observeEvent(input$show, {
    if (input$tab == "1"){
      faqtext = faq1
    }
    else if (input$tab == "2") {
      faqtext = faq2
    }
    else if (input$tab == "3") {
      faqtext = faq3
    }
    
    else {
      faqtext = benchmark_faq
    }
    showModal(modalDialog(
      title = "Guildlines",
      kable(faqtext) %>%
        kable_styling("striped", full_width = F) %>%
        column_spec(1, bold = T, border_right = T),
      easyClose = TRUE
    ))
  })
  
}
shinyApp(ui = ui, server = server)```
2 Likes