Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: dropdown_extra() keeps values in memory even if reactable source data changes #50

Open
1 task done
JMPivette opened this issue Dec 12, 2023 · 3 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@JMPivette
Copy link

JMPivette commented Dec 12, 2023

Guidelines

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

Project Version

0.2.0

Platform and OS Version

No response

Existing Issues

No response

What happened?

if a value is changed using dropdown_extra(), then the value persist on the table even if the source data of my reactable changes.

Steps to reproduce

  1. Create a reactable with dropdown_extra() and with a data source that can change.
  2. Modify some values with dropdown
  3. Change data source and see that changes from step 2 persist

Expected behavior

I was expecting these values to be "flushed" when the data changes.
Or maybe a mechanism to force the refresh

Attachments

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

df1 <- MASS::Cars93[1:4, 1:3]
df2 <- MASS::Cars93[5:8, 1:3]

shinyApp(
  ui = fluidPage(
    reactable_extras_dependency(),
    selectInput("data", "Data", c("df1", "df2")),
    reactableOutput("react"),
  ),
  server = function(input, output) {
    df <- reactive({
      if (input$data == "df1") {
        df1
      } else {
        df2
      }
    })
    output$react <- renderReactable({
      reactable(
        df(),
        columns = list(
          Type = colDef(
            cell = dropdown_extra(
              id = "dropdown",
              choices = levels(df()$Type),
              class = "dropdown-extra"
            )
          )
        )
      )
    })
  }
)

Screenshots or Videos

Screen.Recording.2023-12-12.at.14.53.42.mov

In this example I changed the values "Type" to "Van" on the first 2 lines in df1.
When I switch to df2, the 2 first lines have a "Van" "Type" which is not the case in the dataset.

Additional Information

No response

@JMPivette JMPivette added the bug Something isn't working label Dec 12, 2023
@JMPivette
Copy link
Author

Seems to be linked to changes made here: 75d8f58 to keep input changes when using pagination.

JMPivette added a commit to JMPivette/reactable.extras that referenced this issue Dec 12, 2023
@ramiromagno
Copy link

I second this.

@m-kolomanski
Copy link

Run into similar issue, you can force reactable.extras to reset the values by setting global variable called memory to empty object in browser console, so depending on your context you need to run something like:

shinyjs::runjs("memory = {};")

Additional note: in order to properly flush the values you will need to re-render the whole table (so renderReactable will need to run), the updateReactable function does not work with this trick and inputs hold the values anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants