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

After updating autocomplete, it stopped working #38

Closed
trondeh80 opened this issue Nov 1, 2019 · 2 comments
Closed

After updating autocomplete, it stopped working #38

trondeh80 opened this issue Nov 1, 2019 · 2 comments

Comments

@trondeh80
Copy link

trondeh80 commented Nov 1, 2019

I updated the npm dependency to the latest version (5.1.3), and the plugin stopped working.
When I am debugging autocomplete.js I see that this expression always evaluates to false: keypressCounter === savedKeypressCounter in the "startFetch" function.

This is how we are setting up our autocomplete:

const input = document.getElementById('product');
	const products = getProducts();
	if (products.length && !!input) {
		autocomplete({
			input: input,
			fetch: (text, update) => {
				text = text.toLowerCase();
				const suggestions = products.filter(n => n.label.toLowerCase().startsWith(text));
				update(suggestions);
			},
			onSelect: ({ label }) => {
				input.value = label;
			},
			minLength: 1,
			emptyMsg: 'No matches'
		});
	}

What are we doing wrong?

This was tested on mac os v10.13.6 on a chrome Version 78.0.3904.70 (Official Build) (64-bit)

@kraaden
Copy link
Owner

kraaden commented Nov 1, 2019

I copied your code here:

https://jsbin.com/kasezelaza/edit?html,js,output

and everything seems to work just fine. If I enter 'u' into the input field, it shows suggestions correctly (tested with the same browser & version)

@trondeh80
Copy link
Author

Ok, sounds like we had a bug on our end then. Your component was rendered as part of a material component in our form. We decided to use a drop-down instead for now. Thank you very much for looking in to this, and for creating this awesome plugin.

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

No branches or pull requests

2 participants