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

[Dropdown] Clicking on the dropdown icon will generate multiple hits to the server (when no results are returned). #5231

Open
kmd1970 opened this issue Apr 3, 2017 · 5 comments

Comments

@kmd1970
Copy link

kmd1970 commented Apr 3, 2017

I was just about to upgrade to v2.2.10 when I noticed my remote dropdowns where generating multiple hits to the server when no results are returned. It also looks like the caching parameter is ignored.

For some reason this bug only happens if you click on the actual dropdown icon (you will see the loading icon spin, stop, spin, stop... ).

If you look at the console log you will see multiple repeated requests.

http://jsfiddle.net/kmd1970/pzcm8zo4/
(Please note this link needs to remain http:// for the remote ajax call to work properly)

Looks like this issue started in v2.2.8. In more recent versions (v2.2.7) the dropdown icon doesn't open the empty menu (after load) until you click into the input at least once, so this issue doesn't occur.

@kmd1970 kmd1970 changed the title [Dropdown] Clicking on the dropdown icon will generate multiple hits to the server, when no results are returned. [Dropdown] Clicking on the dropdown icon will generate multiple hits to the server (when no results are returned). Apr 3, 2017
@awgv awgv added this to the Needs Milestone milestone Apr 4, 2017
@awgv
Copy link
Member

awgv commented Apr 19, 2017

Another test case in #5290 where the request loops infinitely:

Remote content dropdown creates infinite loop when clicked on it and server returns empty list response.
Apparently, clicking a remote content dropdown triggers show() function to queryRemote() with a callback to show() function. When server returns empty list, can.show() condition returns false because of has.items() and has.message() is false. Which creates infinite loop.
jsfiddle: https://jsfiddle.net/dhfa4730/
Step to re-produce: after running fiddle, click dropdown arrow.
Result: infinite loop request to server.

@nikolaybobrovskiy
Copy link

A bit critical issue.

@nikolaybobrovskiy
Copy link

Quick work-around is to define own onSuccess in apiSettings:

onSuccess(response, el) {
	el.dropdown('internal', 'remove').message();
	el.dropdown('internal', 'setup').menu({
		values: response.results
	});
	if (response.results && response.results.length) {
		el.dropdown('show');
	}
}

@tcmal
Copy link
Contributor

tcmal commented Apr 28, 2018

From what I understand this means that no message is added. As there's no message & no items, the query gets run again.

@jlukic
Copy link
Member

jlukic commented Jun 18, 2018

I can see the recursion in the logic here. I'll add a solve to next patch release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants