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

Reduces dropdown flicker during a remote search. Fixes #176. #718

Closed
wants to merge 3 commits into from

Conversation

mjstallard
Copy link
Contributor

Hello!

This is a little fix I threw together to address the flickering issue for the project I'm currently working on.

The behaviour of Bloodhound has been changed such that the #get callback is only run if matches in the search index (i.e. local or prefetched) have been found, or if we're not making a network request.

The behaviour of Typeahead has been changed such that the dropdown is only cleared by the query changing if the query becomes an empty string.

As we're not using any local or prefetched sources, this means that we no longer see flickering between network requests. Furthermore, if we were to use local or prefetched sources then any matches would be still immediately available. The result is that we only clear the dropdown when we know for sure that there are no matches.

I'm not sure if this is the sort of thing you had in mind, but thought it was worth sending over anyway.

Thanks for building typeahead.js - really nice little plugin. 😃

The behaviour of Bloodhound has been changed such that the
 #get callback is only run if matches in the search index
 (i.e. local or prefetched) have been found, or if we're
 not making a network request.

The behaviour of Typeahead has been changed such that the
dropdown is only cleared by the query changing if the query
becomes an empty string.

expect(this.dropdown.empty).toHaveBeenCalled();
});

it('should empty dropdown if the query is non-empty', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not empty dropdown menu, right?

@jharding
Copy link
Contributor

jharding commented Mar 7, 2014

Super excited to see this pull request. It seems like it makes sense and it should solve #176, but before merging this I want to do some testing myself. Will try and do that ASAP.

@jharding jharding added this to the v0.10.2 milestone Mar 7, 2014
@jharding
Copy link
Contributor

jharding commented Mar 7, 2014

Played around with your pull request and it looks great! I see no reason why this shouldn't go out in v0.10.2. Thanks for your help!

@jharding
Copy link
Contributor

jharding commented Mar 7, 2014

This landed in integration-0.10.2, thanks again!

@jharding jharding closed this Mar 7, 2014
@mjstallard
Copy link
Contributor Author

Yay, awesome! Thanks for merging 😃

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

Successfully merging this pull request may close these issues.

2 participants