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] Table search not working with onSearchTextChanged #5444

Closed
WillemJann opened this issue Jun 28, 2021 · 18 comments · Fixed by #9505
Closed

[Bug] Table search not working with onSearchTextChanged #5444

WillemJann opened this issue Jun 28, 2021 · 18 comments · Fixed by #9505
Assignees
Labels
Bug Something isn't working Low An issue that is neither critical nor breaks a user flow Needs Triaging Needs attention from maintainers to triage Table Widget Verified When issue is retested post its fixed Widgets Product This label groups issues related to widgets

Comments

@WillemJann
Copy link

Description

For the table widget, if the onSearchTextChanged action is defined the actual search functionality is not working anymore. The onSearchTextChanged action itself is executed, but the search (filter) on the table is not applied.

Steps to reproduce the behaviour:

  1. Create a table widget with some data.
  2. Set onSearchTextChanged to some action (e.g. save the search value in the store or show a message)
  3. Enter a search term. The search filter is not applied, but the action is executed.
  4. Remove the onSearchTextChanged action.
  5. Enter a search term. The search filter is now applied.

Important Details

  • Version: self-hosted, v1.5.5
  • OS: Windows 10
  • Browser: Chrome
  • Environment: production
@WillemJann WillemJann added Bug Something isn't working Needs Triaging Needs attention from maintainers to triage labels Jun 28, 2021
@mohanarpit mohanarpit added Table Widget Widgets Product This label groups issues related to widgets labels Jun 28, 2021
@mohanarpit mohanarpit added the High This issue blocks a user from building or impacts a lot of users label Jun 28, 2021
@Nikhil-Nandagopal
Copy link
Contributor

@WillemJann can you tell us which datasource are you working with? Did you configure the datasource to filter data based on the {{ Table1.searchText }} field?

@WillemJann
Copy link
Author

The datasource of the table is a MongoDB query. The datasource is not configured to filter on the {{ Table1.searchText }} field. That's on purpose, because the default search behavior is in all visible columns of the table, which is very useful.

@Nikhil-Nandagopal
Copy link
Contributor

@WillemJann You can write the logic as {{ Table1.searchText === undefined ? {} : { name: Table1.searchText } }}
so that it defaults to all data when the searchText is empty

@somangshu
Copy link
Contributor

Before a while we have actually made this change in #4039. When we set/bind onSearchTextChanged to an action we stop propagating the client side search.

@WillemJann
Copy link
Author

Ah, I see that this behavior is introduced after #4039.

However, in previous versions of Appsmith we could benefit of the client-side search and additional actions. We use it to remember the search text, with an additional action it is saved in the store. The next time the default search text is read from the store, so that the same filtered table appears.

Client-side search is easier because we don't need to modify all queries to take the searchText into account. Is there no way to combine the client side search with additional actions via the onSearchTextChanged field? In other words, is there a way to continue the propagation when onSearchTextChanged is set.

I started this issue as a bug because it was working in a previous version of Appsmith 😉

@somangshu
Copy link
Contributor

@Nikhil-Nandagopal I think what they need if to save the search text in the store and reference it the next time but let the client side handle the filtering process. @WillemJann Am I getting this right?

@WillemJann
Copy link
Author

Yes, that's exactly right.

@somangshu
Copy link
Contributor

@vicky-primathon do you think this is achievable?

@Nikhil-Nandagopal
Copy link
Contributor

@WillemJann thank you for the details. @somangshu yeah we can have a separate property to disable client-side search.

@somangshu
Copy link
Contributor

@Nikhil-Nandagopal How do we handle disabled client-side search and no onSearchTextChanged action then. It would look like a bug to the end user. There could be other complexity as well here.

@Nikhil-Nandagopal
Copy link
Contributor

@somangshu sounds like a bug the developer introduced so maybe we shouldn't be the ones to handle that? We can also provide explicit options for client side search such as case sensitive, insensitive, prefix match, fuzzy match and disable.

@somangshu
Copy link
Contributor

@Nikhil-Nandagopal going by the first logic and ignoring that we allowed such a use case should work fine. Shall we implement this, It not a lot of effort and can be picked up soon

@Nikhil-Nandagopal Nikhil-Nandagopal added Low An issue that is neither critical nor breaks a user flow and removed High This issue blocks a user from building or impacts a lot of users labels Aug 26, 2021
@Pranay105 Pranay105 added the Good First Issue Good for newcomers label Sep 22, 2021
@riodeuno riodeuno removed the Good First Issue Good for newcomers label Oct 1, 2021
@WillemJann
Copy link
Author

Any update on this? Client-side search is still not working if onSearchTextChanged is set.

@somangshu
Copy link
Contributor

@WillemJann this is not prioritised yet, I will pick this up soon.

Dev Note:

  • Add new property: Disable client side search
    • Enabling this will only search with the action given in onSearchChanged
    • Disabling this will always apply the client side search even when the onSearchChanged is configured

cc @riodeuno @sbalaji1192

@zegerhoogeboom
Copy link
Contributor

I have the exact same use case and am running into the exact same issue after not having updated Appsmith for a while, suddenly the logic of remembering the table filter and doing client-side search is broken.

@Nikhil-Nandagopal
Copy link
Contributor

@zegerhoogeboom can you explain the issue you're seeing with remembering the table filter?
The client side search is applied on top of the server-side search so that needs an option to be disabled which we're working on. A way to get around this is to disable the search option in the table and use an input to perform the server side search. This will not perform any client side search on top of your results

@zegerhoogeboom
Copy link
Contributor

zegerhoogeboom commented Nov 30, 2021

Hi @Nikhil-Nandagopal sure, the issue is exactly like @WillemJann described earlier in this issue. In this image there is an action onSearchTextChanged specified and I'm searching for the text "Drop" which does not filter the results.

image

When no onSearchTextChanged handler is specified the table is filtered

image

What I want to happen, similar to @WillemJann is that client-side search is still done and the onSearchTextChanged handler can work, such that the search text can be remembered when the user e.g. reloads the page. I don't want to do any server-side search in this case. I know you consider this behavior a feature as implemented in #4039 but this behavior was actually very helpful - I guess as long as one is not doing server side filtering.

@WillemJann
Copy link
Author

@zegerhoogeboom this is indeed exactly the issue. When this is solved we can remember the search text of tables and make client-side search happen. Thanks for your explanation!

@sbalaji1192 sbalaji1192 assigned Tooluloope and unassigned somangshu Nov 30, 2021
@Nikhil-Nandagopal Nikhil-Nandagopal added the JS Evaluation Issues related to JS evaluation on the platform label Dec 1, 2021
@github-actions github-actions bot added Javascript Product Issues related to users writing javascript in appsmith Actions Pod labels Dec 1, 2021
@Nikhil-Nandagopal Nikhil-Nandagopal removed JS Evaluation Issues related to JS evaluation on the platform Actions Pod Javascript Product Issues related to users writing javascript in appsmith labels Dec 1, 2021
@close-label close-label bot added the QA Needs QA attention label Dec 9, 2021
@chandannkumar chandannkumar added Verified When issue is retested post its fixed and removed QA Needs QA attention labels Dec 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Low An issue that is neither critical nor breaks a user flow Needs Triaging Needs attention from maintainers to triage Table Widget Verified When issue is retested post its fixed Widgets Product This label groups issues related to widgets
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants