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

Bug: Visual search does not pick up the last value when using a button to trigger search #135

Open
ghost opened this issue Apr 8, 2014 · 3 comments

Comments

@ghost
Copy link

ghost commented Apr 8, 2014

Hey,

First of all awesome plugin. Really is a complete pleasure to use. I think there is a bug though. For my use case I am using a button to trigger the search. This works fine for most cases except for one. If the user types values in and then clicks on the search button without clicking anywhere else or without hitting the tab key then a subsequent call to visualSearch.searchQuery.facets() does not pick up the last value you entered.

I have created a gist (https://gist.github.com/theshadow7/10186153) that demonstrates this issue. It is basically the demo on the official page with a couple of lines added to add a search button and a click event handler that prints visualSearch.searchQuery.facets() to the console.

Steps to reproduce:

  1. Use the attached html file
  2. Enter a few values in the search box, make sure you type the last one (eg address: myaddress)
    3.Click the search button.
  3. In your console you will see that the last value of address is empty

If you click search again now you will have the right value for address.

For example if I enter
country: United States account: 5-samuel U.S. State:California address: aaa

and click the search button directly the output is
[Object { country="United States"}, Object { account="5-samuel"}, Object { U.S. State="California"}, Object { address=""}]

If you change the click hander to this:

$('#searchButton').click(function(event) {
window.setTimeout(function() {
console.log(visualSearch.searchQuery.facets());
}, 200);
})

Then visualSearch.searchQuery.facets() gives the right output.

@michael-harrison
Copy link

+1 I'm having the same problem

@cousine
Copy link

cousine commented May 18, 2015

So after a lot of poking around, I found a workaround; you can override the click even on the button and add the following to trigger visualsearch to detect the facets:

visualSearch.searchBox.disableFacets();

hope this helps any other soul trapped with this legacy!

@zekedroid
Copy link

@cousine thank you so much! that was a great solution to this problem.

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

No branches or pull requests

3 participants