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

searchTreeview behaves strangely #16

Open
flash0926 opened this issue Jun 30, 2024 · 2 comments
Open

searchTreeview behaves strangely #16

flash0926 opened this issue Jun 30, 2024 · 2 comments

Comments

@flash0926
Copy link

According to the sample code, after adding this search function on the server side.
By default, all levels will be expanded and all countries will meet the conditions.
searchTreeview( inputId = "country", pattern = input$search, reveal_results = TRUE )
I think it is the pattern field.
When no search value is entered, the passed pattern is "", and the code will think that this "" can be matched by any string.
I have tried to set it to NA or NULL, but the performance is abnormal.
Setting it to NA is the same as setting it to ""
Setting it to NULL, although it meets expectations in the default state. However, once a search is performed, the performance status will not be refreshed after resetting to NULL.
How to deal with this?

@pvictor
Copy link
Member

pvictor commented Jul 1, 2024

Hello,

I added `` function to clear the the search, so now you can check that the search pattern is truthy and then search for it or clear the search, e.g. :

observeEvent(input$search, {
  if (isTruthy(input$search)) {
    searchTreeview(
      inputId = "country",
      pattern = input$search,
      reveal_results = TRUE
    )
  } else {
    clearSearchTreeview("country")
    collapseTreeview("country")
  }
})

@flash0926
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants