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 Breaks When Results is Null #472

Open
harryfear opened this issue Aug 9, 2022 · 1 comment
Open

AutoComplete Breaks When Results is Null #472

harryfear opened this issue Aug 9, 2022 · 1 comment

Comments

@harryfear
Copy link

After a null result dataset is gotten, further autocompletes are broken.

What should happen is that the null dataset is ignored and further autocompletes with data are shown normally.

What does happen is that further datasets that should have results are not presented as an uncaught error has already broken the autocomplete instance.

When dataresult result is a null rather than an empty array, this error occurs:

Cannot read properties of null (reading 'length')

@harryfear
Copy link
Author

harryfear commented Aug 9, 2022

Suggesting this edit to L1112 of jquery.easy-autocomplete.js:

if (listData.length === 0) { continue; }

with:

if ( listData === null || listData === undefined || listData === '' ||
            (Array.isArray(listData) && listData.length === 0) ||
            (!(listData instanceof Date) && typeof listData === 'object' && Object.keys(listData).length === 0) ) {
	continue;									
} // https://stackoverflow.com/a/72597733/8800423

if (listData.length === 0) {
	continue;
}

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

1 participant