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

Trigger search when submitting search form #2457

Merged
merged 2 commits into from
Jun 29, 2023
Merged

Conversation

yscik
Copy link
Contributor

@yscik yscik commented Jun 16, 2023

Fixes #2304

Changes proposed in this Pull Request

  • When using AJAX search, which submits the search whenever an input changes, also do the search when clicking the 'Search Jobs' button

Testing instructions

  • Go to the Jobs page and use the search form

Notes

There is a bit of trade-off here. The search so far triggers on change events, which occurs when unfocusing an input. And that happens when the users moves to click the submit button. So in most cases the search would happen anyway. And in fact, with this change, the search request is duplicated, because both the change event and the submit event triggers it.

The code cancels the ongoing search request when a new one is issued, but in this case it might make more sense to only trigger the search on submit when it's not already going on?

@yscik yscik requested a review from a team June 16, 2023 12:43
@yscik yscik marked this pull request as ready for review June 16, 2023 12:43
@mikeyarce
Copy link
Member

I tested this out but on my test site I never see another request happen when clicking "Search Jobs". I can see triggerSearch is called, but it never calls update_results.

@yscik yscik added this to the 1.41.0 milestone Jun 27, 2023
@gikaragia
Copy link
Contributor

Hey @mikeyarce and @yscik, I added a commit which does the following:

  • It passes the selected element to triggerSearch to fix the issue that Mikey mentioned above
  • It checks if there is a pending search before triggering a new search.

Let me know your thoughts.

@yscik
Copy link
Contributor Author

yscik commented Jun 28, 2023

Thanks @gkaragia, that's a great approach. Code looks good, but I can't approve as the PR author :)

@gikaragia gikaragia merged commit 6ad3986 into trunk Jun 29, 2023
7 checks passed
@gikaragia gikaragia deleted the fix/search-submit branch June 29, 2023 07:33
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

Successfully merging this pull request may close these issues.

Submit Button on Filters page does not do anything
3 participants