Page 1 of 2
Choices url on a textbox : set autocompletion manually
Posted: Mon Feb 04, 2019 9:25 am
by mgardes
Hello
In a Rich Display File i have a textbox autocompleted by using the "Choices url" property (with a json list geted with Universal Handler);
It works well.
But i would like that the autocompletion does not start atomatiquely but manually using javascript (on the onkeyup event for exemple) to add a setTimeout/clearInterval functionnality to avoid the search programm to be called when the user type very fastly a word in the textbox.
Does someone coud say me how to do please ?
Thank you very much
Re: Choices url on a textbox : set autocompletion manually
Posted: Tue Feb 05, 2019 3:54 pm
by matt.denninghoff
Hi,
Currently, there is a 200 millisecond delay between the keyup event and when the AJAX request is sent to your Universal Display File program. The 200ms delay happens internally with the Autocomplete via setTimeout. That means, when a user types quickly (without 200ms expiring between key strokes), then fewer AJAX requests are sent.
There's not currently a way for you to change that 200ms delay or to run some custom JavaScript to run before the AJAX request. However, it would be easy for Profound to add an option to our product to allow the delay to be changed. If that config option is something you'd be interested in, you can request a feature by emailing
support@profoundlogic.com.
Re: Choices url on a textbox : set autocompletion manually
Posted: Wed Feb 06, 2019 8:37 am
by mgardes
Thanks a lot Matt for all theese informations.
The problem is not the delay but the comportement.
when the user types quickly, the most important step is the last one and not the older one. Each time a key is up it should cancel the last ajax request timeouted via a clearInterval if this one has not been executed yet) . That means that, as long as you quickly type keys, its should cancel all the ajax requests exepted the last one when you stop. This is not what happens today.
Today, when you type quickly, most of the time, your last keys are not "taken in account"
if i type "maximilien" very quicly today it searchs "m", "max", "maximli" (and not "maximilien") but it should only search "maximilien" because the last letter is the first one after which there is a delay before the next letter.
Do you agree ?
PS : i hope my english is clear enough
Re: Choices url on a textbox : set autocompletion manually
Posted: Wed Feb 06, 2019 6:32 pm
by matt.denninghoff
Your English is clear to me. I'm sorry--my answer was not complete: if the user types before the delay/timeout expires, then clearTimeout() is called, and the earlier keystrokes should not each fire the event that makes the AJAX. So, if you type quickly enough (with less than 200ms between each keystroke), AutoComplete is coded to only fire the AJAX request once.
In my testing, the AJAX calls happen as I described if I type very quickly. However, I'm seeing that 200ms is very short. It's very hard for me to type "maximilian" without a 200ms delay after any of those keys. (I can type "matthew" fast enough:) The timeout should probably be increased to 500ms--or better yet, be configurable. I can put in a feature request if you'd like.
Re: Choices url on a textbox : set autocompletion manually
Posted: Thu Feb 07, 2019 5:32 am
by mgardes
Thank you so much Matthiew.
I understand the behavior better.
On the other hand, I come to understand that the problem also comes from elsewhere by carrying out new tests:
Look at the attached image:
When I type "39306" normally, this triggers 5 searches: "39", "393", "3930", "39306" and again "39306". I see it by looking at the content of the POST variables of the queries. We see them below in the order of tripping.
When we look at the bottom queries, we see that they are asynchronous and that the answers do not arrive in the same order.
Typing 39306 I first see the results of "3930" (the third), then "393" (the second), then "39306" (the 4th and 5th) and suddenly I see the results of " 39 "because it is the query that has taken the most time. This is not the expected behavior at all.
We have just done tests with different delays (300ms, 400ms, 500ms) by temporarily modifying the file "runtime.js". It's better because suddenly there are fewer requests. So please ask for the opportunity to customize this time. It will be very good.
On the other hand it still happens that the answers do not arrive in the right order and that the results do not suffice the good ones. An idea to avoid this?
Re: Choices url on a textbox : set autocompletion manually
Posted: Thu Feb 07, 2019 11:01 am
by matt.denninghoff
The results arriving out of order is unusual, but the AutoComplete code isn't coded to prevent it. If we're adding the configuration option to specify the delay, we may as well look at the out-of-order problem, too. I don't think there's a way to solve the out-of-order problem without us changing the code, so I'll make a ticket and add both problems to it. I'll let you know next week what our developers decided on it.
Re: Choices url on a textbox : set autocompletion manually
Posted: Thu Feb 07, 2019 11:57 am
by mgardes
great !!! Thanks a lot, one more time !
Re: Choices url on a textbox : set autocompletion manually
Posted: Tue Feb 12, 2019 11:49 am
by matt.denninghoff
Hello. The results arriving out of order is a bug. I've fixed it, but for bugs, those should normally be reported to
support@profoundlogic.com. Please contact Support and ask for a patch for issue #5136, or you can wait for the next release of Profound UI.
I also added a configuration option, pui["autocomplete typeahead delay"], which will be available in the next release or the same patch. See
http://www.profoundlogic.com/docs/displ ... head+Delay for how it will be used.
Re: Choices url on a textbox : set autocompletion manually
Posted: Thu Feb 14, 2019 9:55 am
by mgardes
Great. Thanks a lot.
Mail sended to have a patch.
Re: Choices url on a textbox : set autocompletion manually
Posted: Fri Feb 15, 2019 9:04 am
by mgardes
The patch works perfectly. Great job. Thank you so much.