Search code examples
rshinyreactablecrosstalk

Ampersand (&) in a string becomes "&" in crosstalk filter_select() function


I am using NFL Stadium names in a crosstalk filter_select() function for my r shiny app using a reactable table. However, when I go to select "M&T Bank Stadium", it displays as "M&[amp;]T Bank Stadium" (I have added the brackets so you see what it looks like). Is there a way to have the crosstalk filter_select show "M&T Bank Stadium" and not "M&[amp;]T Bank Stadium?"

I've made a quick MRE below

library(reactable)
library(tidyverse)
library(crosstalk)
library(shiny)

df <- tibble(points = c(10, 12, 14), 
             stadium = c("M&T Bank Stadium", "Wembley Stadium", "FirstBank Stadium"))

df_crosstalk <- SharedData$new(df)

df_react <- 
  reactable(df_crosstalk)

ui <- fluidPage(
  titlePanel("Test Ampersand"),
  fluidRow(
    column(
      4,
      filter_select(
        id = "stadium",
        label = "Stadium",
        sharedData = df_crosstalk,
        group = ~`stadium`)
      ),
    column(
      8,
      df_react
    )
  )
)

server <- function(input, output, session) {
  output$table <- renderReactable({
    df_react
  })
}

shinyApp(ui, server)

Solution

  • For anyone with the same problem, this has been fixed here: github.com/rstudio/crosstalk/issues/87