documentcloud / visualsearch

A Rich Search Box for Real Data
http://documentcloud.github.io/visualsearch/
MIT License
1.8k stars 225 forks source link

Hitting tab after entering text causes incorrect behavior #88

Closed dbrunner closed 11 years ago

dbrunner commented 11 years ago

Hitting the tab key instead of the return key after entering text in the visual search input results in strange behavior, as follows.

If I enter "notafacet" and hit the enter key, I get the result "TEXT:notafacet", which seems like correct behavior.

However, if I hit the tab key instead of the enter key, I get the result "NOTAFACET:", which then allows me to enter text as if I were searching by the notafacet facet.

The behavior is even weirder with a string like "not a facet". If I hit enter after the text, I get "TEXT:not a facet" as expected. However, if I hit the tab key instead of enter, I get "TEXT: not a facet" followed by "NOT A FACET:" in a new search facet.

There are several issues here:

  1. Tab and enter should probably have the same behavior when pressed after entering search text.
  2. Non-facets should not be displayed as if they were search facets.
  3. The behavior that occurs when hitting tab after entering multiple words separated by spaces is just buggy.

All of these issues were reproduced in the search input at http://documentcloud.github.com/visualsearch/

jashkenas commented 11 years ago

For what it's worth -- the behavior is due to the fact that in DocumentCloud (the original implementation), it's likely to have valid user-defined facets that the client doesn't know about. So you need to be able to enter anything as a facet, if you wish.

That said, if you want to contribute an option that turns this behavior on and off...