documentcloud / visualsearch

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

Entering in special chars in the search field cause it to select first category #103

Open schaitanya opened 11 years ago

schaitanya commented 11 years ago

Steps to create:

  1. Type 8.25% in the text field. (You can also just type any special char anywhere like $ etc and hit enter)
  2. The text will disappear and the first category will show with empty value.

Expected behavior

  1. Show the entered text under 'text' category.

This can be seen on the demo page

mewynn commented 10 years ago

You can fix this bug yourself :

The problem is autocomplete menu is displayed if a category match the last word or if last word is empty. The regx that match last word in code doesn't work properly.

Just replace : var lastWord = searchTerm.match(/\w+?$/); // Autocomplete only last word. by var lastWord = searchTerm.match(/[^\ ]$/); // Autocomplete only last word.

on autocompleteValues function on SearchInput definition.