Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

typeahead-loading and typeahead-min-length problem when using together #1140

Closed
a70babat opened this issue Oct 8, 2013 · 1 comment
Closed

Comments

@a70babat
Copy link

a70babat commented Oct 8, 2013

Hi,
I have following input with typeahead
<input type="text" ng-model="drug" typeahead-min-length="2" typeahead-loading="isLoading" ng-class="{loading: isLoading}" typeahead="drugItem as drugItem.english_name for drugItem in getDrugItems($viewValue)">

When I remove all characters in input quickly, isLoading will remain true.
I tweak typeahead javascript code I buy following changes the problem is solved:
typeahead.js line 151-164 original:

if (inputValue && inputValue.length >= minSearch) {
    if (waitTime > 0) {
        if (timeoutPromise) {
            $timeout.cancel(timeoutPromise);//cancel previous timeout
        }
        timeoutPromise = $timeout(function () {
            getMatchesAsync(inputValue);
        }, waitTime);
    } else {
        getMatchesAsync(inputValue);
    }
} else {
    resetMatches();
}

last 3 lines should changed to:

else{
    resetMatches();
    isLoadingSetter(originalScope, false);
}

I'm not familiar on how to contribute to a git repository, but I hope the explanation be clear.

@pkozlowski-opensource
Copy link
Member

Thnx for the clear bug report @a70babat it is fixed in master now! If only half of all the bug reports would look like this GitHub would be a better place... And hey, by all means learn about git / GitHub so you can contribute by sending pull requests :-)

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

No branches or pull requests

2 participants