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

updateSearch() doesn't filter in the same way manual filters do #1082

Closed
3 tasks done
DavidBlairs opened this issue Sep 1, 2023 · 1 comment
Closed
3 tasks done
Assignees
Labels

Comments

@DavidBlairs
Copy link

Hello!

I've encountered a bug in the updateSearch function that is making it rather unusable. The code to reproduce it can be found below:

library(shiny)
library(DT)

ui <- fluidPage(
  actionButton("change_filters", "Change Filters"),
  DTOutput("mytable")
)

server <- function(input, output, session) {
  output$mytable <- renderDT(datatable(iris, filter = "top"))
  
  proxy <- dataTableProxy("mytable")
  
  observe({
    print(input$mytable_search_columns)
  })
  
  observeEvent(input$change_filters, {
    updateSearch(proxy, keywords = list(global = NULL, columns = c("", "", "", "", "", "[\"setosa\"]")))
  })
}

shinyApp(ui, server)

If you open this app and click the button labelled "change_filters", it works as expected and adds the categorical filter to the last column in the the table. However:

  1. The first issue you'll notice is that the button that allows you to remove the filters (a black circle with a black x in the in the middle on the right of the filter box) is not there and you need to click inside of the filter box and out again for it to appear. This is perhaps the lesser of the two issues.
  2. The second issue is that if you remove this filter, the table does not update. As well as this, while applying other filters manually works as expected, you are never able to return to the original completely unfiltered dataset from this point onwards.

I've tried updating the package and using the latest development version but this doesn't seem to work.


By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('DT'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/DT').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@yihui yihui added the bug label Sep 1, 2023
@yihui yihui closed this as completed in b6de4ac Sep 2, 2023
@yihui
Copy link
Member

yihui commented Sep 2, 2023

Should be fixed now. Thanks so much for the nice minimal reproducible example!

remotes::install_github('rstudio/DT')

@yihui yihui self-assigned this Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

No branches or pull requests

2 participants