Skip to content

crosstalk: selection interaction is wrong, it filters rows instead of selecting/highlighting #320

@daattali

Description

@daattali

The {crosstalk} package provides functionality to link shiny widgets in two ways: selection and filtering. reactable implements filtering correctly, and when rows in a reactable table are selected then it correctly sends the selection signal. However, when rows are selected externally, reactable does not correctly show the selection - it filters for these rows instead of highlighting them.

In the example below, if you use the filters, then both the plot and the table will show filtered data. This is correct. If you select rows in the table, then the corresponding data points will highlight in the plot. This is also correct. But if you highlight points in the plot, then the table will filter out the other data instead of highlighting the selected data.

library(shiny)

df <- crosstalk::SharedData$new(cars)

ui <- fluidPage(
  crosstalk::filter_slider("speed", NULL, df, "speed"),
  d3scatter::d3scatterOutput("plot"),
  reactable::reactableOutput("table")
)

server <- function(input, output, session) {
  output$plot <- d3scatter::renderD3scatter({
    d3scatter::d3scatter(df, ~speed, ~dist)
  })
  output$table <- reactable::renderReactable({
    reactable::reactable(df, selection = "multiple")
  })
}

shinyApp(ui, server)

Metadata

Metadata

Assignees

No one assigned

    Labels

    docDocumentation issue or suggestion

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions