[Search and Autocomplete] Can I modify time delay between typing and search starting

[Search and Autocomplete] Can I modify time delay between typing and search starting

  
Forge Component
(15)
Published on 15 Feb by Leonardo Fernandes
15 votes
Published on 15 Feb by Leonardo Fernandes
Is there any way to adjust the time delay between keypress and search being activated - or maybe the number of keys?

Cheers,
Gavin
Hi, Gavin.
The input delay is the same as the OutSystems platform uses by default, which is 800ms. However, it's not possible to override this value for the autocomplete component.

But you can use the javascript APIs, which are fairly easy to use. They are not documented (yet), but the following code should work (you only need to include this once):

$(function() {
    var timeout;

    $("body").on("input", ".lfs-search-container input, .lfs-search-container textarea", function(evt) {
        var autocomplete = $(this).lfs().autocomplete();

        window.clearTimeout(timeout);
        timeout = window.setTimeout(function() {
            autocomplete.open();
        }, /* customize the timeout value in milliseconds: */ 100);

        evt.stopPropagation();
    });
});
Note that this is one of those settings that is impossible to tune for every user. Some users will type quickly, and therefore the default wait timeout will seem like an eternity. Other users will type slowly, and they can be distracted by constant updates on the search results. Having one setting per user would also not work, because typing speed changes with the device they use.
Thanks Leonardo, you're absolutely right on the difference between users and devices.  I'll have to try and find a happy medium - it's probably 800ms :)