Despite checking the " Search also in the middle of words " checkbox, chosen widgets will not return any result unless starting from the beginning of the search term.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tymn’s picture

I'm also experiencing this issue with the latest recommended and dev releases. As well as 'search in the middle' not working it was also not using my custom placeholder text. I've reverted back to the previous version I was using (7.x-2.0-alpha2+13-dev) which is working fine.

MiroslavBanov’s picture

Title: Won't search in middle of words » Chosen widgets won't search in middle of words
Issue summary: View changes
Status: Active » Needs review
FileSize
2.24 KB

The bug is that widgets do not receive the settings/options of chosen.
Problem was introduced with this commit https://drupal.org/comment/7876589#comment-7876589
of this patch https://drupal.org/comment/7861437#comment-7861437
The settings/options had to be applied for every matched select, but there are two selectors in the chosen js behavior.

Attached is a patch that resolves the problem, without duplication of code.

maximpodorov’s picture

Status: Needs review » Reviewed & tested by the community

The correct fix.
Marking my issue as duplicate: #2170113: Options for widgets are lost

maximpodorov’s picture

Any plans to accept this patch?

maximpodorov’s picture

@Dave Reid, excuse me for the annoyance, do you think it's a right fix?

Dave Reid’s picture

I think it does although the way it is implemented as a var which is a function doesn't actually seem correct.

Just looking at the code, I don't understand why we can almost have a complete options object provided in Drupal.settings.chosen, and use that rather than having to 'construct' it every time.

maximpodorov’s picture

It's because of 'width' parameter (part of options) which is calculated for every element separately.

Dave Reid’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
4.94 KB

So we were a little on the right track with having a function to get the options, but I improved it a bit more. All of the default options are not contained in Drupal.settings.chosen.options. I've tested this and it seems to work much better and helps simplify stuff that needs to be applied to every chosen element (like minimum width calculation).

Dave Reid’s picture

Title: Chosen widgets won't search in middle of words » Options not set properly on widget select elements if the global selector does not match
Dave Reid’s picture

Forgot inherit_select_classes...

Dave Reid’s picture

Status: Needs review » Fixed

Tested and committed #10 to 7.x-2.x: http://drupalcode.org/project/chosen.git/commit/3816a20

maximpodorov’s picture

Thanks. Chosen is usable now.

Status: Fixed » Closed (fixed)

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