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

Fetch on input event instead of keyup event #101

Merged
merged 2 commits into from
Feb 6, 2023

Conversation

jivdhaliwal
Copy link
Contributor

@jivdhaliwal jivdhaliwal commented Jan 30, 2023

What

Changes the way we fetch results by listening for input events instead of keyup events.

Why

Historically Autocomplete has relied on keyup events to decide when to fetch results.

Text can be submitted in to a field without triggering a keyup event, which results in the user not seeing results until they send another keyup event (for example by adding a space).

This behaviour has resulted in issues like #52 (comment), #78, #91, and #100.

Input events are fired when the value of an input field has changed (https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event), which allows for many different kinds of input methods that may not trigger a keyup event. For example when a user pastes text or selects an auto correct suggestion on mobile.

Jiv Dhaliwal added 2 commits January 30, 2023 11:54
Previously we were using the keyup event to decide when to fetch
autocomplete results. This approach resulted in us having to declare a
list of keys to ignore to avoid unecessary / unintended fetches.

Instead of listening for keyup events, we can simply listen for changes to
the text in the input field and fetch based on that.

This approach allows many forms of input that may not trigger a keyup event.
For example right clicking and pasting from clipboard, or tapping a autocorrect
suggestion on a mobile device.
@kraaden kraaden merged commit cced218 into kraaden:master Feb 6, 2023
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.

None yet

2 participants