yalabot / angular-foundation

http://pineconellc.github.io/angular-foundation/
Other
1.05k stars 267 forks source link

Fix Typeahead focus out #210

Closed diogotrentini closed 9 years ago

diogotrentini commented 9 years ago

Hey guys!

I found a bug on the typeahead directive: it's not updating the loading callback if the input field loses focus. You can test it on http://plnkr.co/edit/VZOjJLO4nZ5HMWXrl9Wc?p=preview, just type something and immediately focus out. I just changed when the directive updates the loading callback and it's working. :smile:

jbrowning commented 9 years ago

Thanks @diogotrentini. What's the use case for this? I'd argue that the typeahead should be closed if the field loses focus.

diogotrentini commented 9 years ago

Hi @jbrowning! It's happening while waiting for a async request (that's why I put a $timeout on the plunker, so I can simulate a async function). So the use case is something like this: I'm fetching via AJAX the items that I want to display on typeahead and using typeahead-loading to show a spinner. If I focus out when the AJAX is still running, the spinner will not hide (typahead-loading will not update, ever).

jbrowning commented 9 years ago

Got it. Makes sense. I would also test that typeahead-loading is set to false if the promise is rejected because this change causes that too.

diogotrentini commented 9 years ago

Sorry for the delay. Actually, isLoadingSetter(originalScope, false); was being called on the promise's rejection, even before this update. Even though I added a test, just to make sure (and because there aren't tests about this case). (:

jbrowning commented 9 years ago

Looks great. Thanks! :+1: