I have Chosen enabled on a site. On most forms when I use the chosen search, it matches for multiple words, but not if the select list is an entityreference_filter.
So in a custom form with a select list with "United States" as an option, I can type "united st" and "United States" shows up. But in an Views exposed filter with "United States" as an option, I can type "united " and it will show up, but "united s" and it says there are no results.
I tracked this down to the regular expressions that chosen uses and noticed that the select options from the Views exposed filter have extra whitespace around them, where the custom form does not.
Example: <option> United States </option>
It looks like chosens main regular expression fails for: /^united/i.test(' United States ');, but they do a fallback split on the words, and /^united/i.test('United'); passes. But for /^united\ s/i.test(' United States '); fails and then the fallback also fails: /^united\ s/i.test('United');
Proposed solution is to trim whitespace from the entityreference views results before returning them, so that Chosen's first regular expression will pass in both cases.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | entityreference_filter-chosen_multiword_search-2554887-2.patch | 987 bytes | jojonaloha |
Comments
Comment #2
jojonaloha commentedAttached patch loops through views results and trims the values before returning them.
Comment #4
maximpodorov commentedThe patch is committed (with modifications).