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.

Comments

jojonaloha created an issue. See original summary.

jojonaloha’s picture

Status: Active » Needs review
StatusFileSize
new987 bytes

Attached patch loops through views results and trims the values before returning them.

  • jojonaloha authored a8f8642 on 7.x-1.x
    Issue #2554887 by jojonaloha: Clean entity reference views style output
    
maximpodorov’s picture

Status: Needs review » Fixed

The patch is committed (with modifications).

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.