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

Autocomplete fixes (race condition, prevent autofill, style fixes) #173

Merged
merged 2 commits into from
Jul 18, 2024

Conversation

kochis
Copy link
Collaborator

@kochis kochis commented Jul 18, 2024

  • Fixes a race-condition on autocomplete requests
  • Disable browser autofill for address autocomplete
  • Autocomplete style fixes

Race Condition

There is a subtle race condition in the autocomplete component that exists when a previous request completes before the latest request. In the scenario where multiple requests are in-flight, the first request to complete sets the results (regardless if the user has typed more characters). The fix is to cancel any in-flight requests when another is issued.

Note: responses are manually throttled down in the examples to demonstrate the issue

Race Condition:

bad_query.mov

Fix:

good_query.mov

@kochis kochis requested a review from jaspk06 July 18, 2024 21:05
Comment on lines +171 to +173
// disable browser autofill
this.inputField.setAttribute('autocomplete', 'off');

Copy link
Contributor

Choose a reason for hiding this comment

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

do we wanna pass this in as an option to in case someone wants to use autofill?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think in that scenario, they can use their own input field.

@kochis kochis merged commit b4f45dc into master Jul 18, 2024
3 checks passed
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.

2 participants