Fixed tab logic. See:
https://github.com/golubev/visualsearch/blob/master/lib/js/views/search_input.js#L393
Current master allows to add any facet that is not in the list of facets, provided in the facetMatches callback. E.g. type "qwerty" and then press the tab button - a new facet with a category "qwerty" will be added, but "qwerty" is not in the list of available facets.
Or another strange behaviour is observed: type "qwerty city", then press the "down arrow" button (to deselect autocomplete menu - to fire exactly this event, but not the autocomplete's select callback) and then press the tab button - "TEXT: qwerty city" will be added.
Proposed fix adds the same logic to this event as when typing the colon. Providing the same input in this fixed version will lead to the same logic as described above: "qwerty" as a remainder and a category "locality" (value for "city" - there are some details in the next paragraph) - as a facet.
when we add a new facet we use facetToAdd.value || facetToAdd.label || facetToAdd for the category - as the jQuery's autocomplete puts value into the input when selected something;
when user types we match his input against facetToAdd.label || facetToAdd.value || facetToAdd - as the label is the text that one can see in the autocomplete's dropdown menu. So it seems to me that user will try to input smth. like the label. See: https://github.com/golubev/visualsearch/blob/master/demo.html#L446
Thanks for this PR. This is quite a big one, so I'll only have time to look at it in a few weeks. Ping me if it takes too long. This will require some testing and verification.
Added
addFacet
method to theSearchInput
(see a comment above the function definition): https://github.com/golubev/visualsearch/blob/master/lib/js/views/search_input.js#L94Fixed colon (
:
) logic. See: https://github.com/golubev/visualsearch/blob/master/lib/js/views/search_input.js#L357 E.g. try to type "qwerty filter" using the current master (http://documentcloud.github.io/visualsearch/demo.html) and then type the colon - nothing happens. The fix that is proposed allows VisualSearch to add "qwerty" as a remainder and "filter" - as a facet in this case.Fixed tab logic. See: https://github.com/golubev/visualsearch/blob/master/lib/js/views/search_input.js#L393 Current master allows to add any facet that is not in the list of facets, provided in the
facetMatches
callback. E.g. type "qwerty" and then press the tab button - a new facet with a category "qwerty" will be added, but "qwerty" is not in the list of available facets. Or another strange behaviour is observed: type "qwerty city", then press the "down arrow" button (to deselect autocomplete menu - to fire exactly this event, but not the autocomplete'sselect
callback) and then press the tab button - "TEXT: qwerty city" will be added. Proposed fix adds the same logic to this event as when typing the colon. Providing the same input in this fixed version will lead to the same logic as described above: "qwerty" as a remainder and a category "locality" (value
for "city" - there are some details in the next paragraph) - as a facet.Fixed facets
value
andlabel
autocomplete items properties usage. To see search "label" through the https://github.com/golubev/visualsearch/blob/master/lib/js/views/search_input.js. The main point is that:facetToAdd.value || facetToAdd.label || facetToAdd
for the category - as the jQuery's autocomplete putsvalue
into the input when selected something;facetToAdd.label || facetToAdd.value || facetToAdd
- as thelabel
is the text that one can see in the autocomplete's dropdown menu. So it seems to me that user will try to input smth. like the label. See: https://github.com/golubev/visualsearch/blob/master/demo.html#L446