Skip to content

[Bug]: Sorting table crashes an app when using server side rendering on a reactive dataset #57

@calderonsamuel

Description

@calderonsamuel

Guidelines

  • I agree to follow this project's Contributing Guidelines.

Project Version

0.2.0

Platform and OS Version

I tested in windows and linux

Existing Issues

No response

What happened?

For context: I have to use a reactive dataset for a project. Since reactable_extras_server() is meant to receive a dataframe, I have to put it inside an observer.

However, once the reactive dataset gets modified and I try to sort a column, my app crashes.

Steps to reproduce

library(shiny)
library(reactable)
library(reactable.extras)


ui <- fluidPage(
  selectInput("dataset", "Choose:", c("mtcars", "iris"), "mtcars"),
  reactable_extras_ui("test")
)
  

server <- function(input, output, server) {
  
  dataset <- reactive({
    if (input$dataset =="mtcars") mtcars else iris
  })
  
  observe({
    reactable_extras_server(
      "test",
      data = dataset(),
      total_pages = ceiling(nrow(dataset())/10)
    )
  }) |> 
    bindEvent(dataset())
}

shinyApp(ui, server)

Two ways to break:

  1. Run code snippet. Starts with mtcars.

  2. You can sort by any column (only for the current page, but that is a different problem)

  3. Select the "iris" dataset. Crash

  4. Run code snippet. Starts with mtcars.

  5. Select the "iris" dataset.

  6. Try to sort the table by the "Sepal.Length" column (or any column). Crash
    ...

Expected behavior

I expect to be able to sort the table without breaking the app

Attachments

This is the error message in the console

Warning: Error in dplyr::arrange: ℹ In argument: `..1 = Sepal.Length`.
Caused by error:
  ! object 'Sepal.Length' not found
64: <Anonymous>
  63: signalCondition
62: signal_abort
61: abort
60: h
59: .handleSimpleError
58: eval
57: mask$eval_all_mutate
56: mutate_col
54: mutate_cols
53: mutate.data.frame
51: arrange_rows
50: arrange.data.frame
48: sort_table
45: ::
  shiny
observe
44: <observer>
  1: runApp

Screenshots or Videos

  1. Run code snippet. Starts with mtcars.
  2. You can sort by any column (only for the current page, but that is a different problem)
  3. Select the "iris" dataset. Crash
Grabacion.2024-06-10.112835.mp4
  1. Run code snippet. Starts with mtcars.
  2. Select the "iris" dataset.
  3. Try to sort the table by the "Sepal.Length" column (or any column). Crash
Grabacion.2024-06-10.112749.mp4

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions