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 changeQuery event when user inputs something into the search field #945

Conversation

SanderKleykens
Copy link

Description

This closes #944 by triggering a changeQuery event as soon as the user inputs something into the search field.

Types of changes

  • Chore (tooling change or documentation change)
  • Refactor (non-breaking change which maintains existing functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@SanderKleykens SanderKleykens changed the title Feature/trigger change query event Trigger changeQuery event when user inputs something into the search field Apr 16, 2021
@mtriff
Copy link
Member

mtriff commented Dec 31, 2021

This looks like a great addition, but right now it won't function as intended. A changeQuery event will be fired every time a key is pressed, even if it doesn't actually change the query (i.e. arrow keys, delete/backspace keys when the query box is empty, etc.). I think you want to hook into the input event instead. We aren't doing that already, so you'll need to add an _onInput method to Choices.

Please also rebase on the latest version of the master branch.

},
false,
);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add a check to ensure that changeQuery is fired before the search event. You can see an example of firing the search event here.

@mtriff mtriff added the changes required Pull request requires changes before it can be merged label Jan 13, 2022
@Xon
Copy link
Collaborator

Xon commented Aug 22, 2024

#1166 implements an _onInput event handler and only triggers a search event if the search has run on new input basically resulting it being identical to this changeQuery functionality.

What I've just added is a search even which gives an empty search string (and result count of 0) when search has finished.

@Xon Xon closed this Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes required Pull request requires changes before it can be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trigger an event as soon as the user inputs something in the search input field
3 participants