Chosen: Bug when searching non-ASCII languages

Created on 29 May 2017  ·  5Comments  ·  Source: harvesthq/chosen

hi
I am using chosen 1.7.0 JQuery in my asp.net MVC project. It works perfect in English, but in my case when I use chosen in multi-select mode for Persian language the search text shows just last charterer instead of whole word. i have work around it and found the problem happens in line 394 , 395 of "chosen.jquery.js" when creating tag.
no difference whether using rtl option or not the result is the same.
1
2

thanks in advance.

Bug

Most helpful comment

Thank you, this helped me a lot
I had to remove ( .substr(startpos); ) from line 395 to fix the issue. i'm using Arabic.

All 5 comments

Thank you, this helped me a lot
I had to remove ( .substr(startpos); ) from line 395 to fix the issue. i'm using Arabic.

Based on #2819, it sounds like there might be a similar issue with Chinese (a regression in search between 1.6.2 and 1.7), so this might not be limited to RTL languages.

Based on the .substr(startpos) highlighted above, it might be a multi-byte char issue? That would affect a number of non-ASCII languages, not just RTL ones.

Hi, I've got the same problem with cyrilic languages. Signed up on the topic and waiting for solution)

As temp solution, commented this string:
option.search_text = text.substr(0, startpos) + '<em>' + text.substr(startpos);

Today I learned that \w and \b are ASCII-specific in JavaScript — they do not work for characters outside the ASCII character range.

I’m working on an alternative solution to #1483, but just wanted to post here because it was surprising news to me and thought you might be interested in learning, too!

This was fixed in #2877 and has been released as part of version 1.8.1.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

asvetlenko picture asvetlenko  ·  3Comments

jbrooksuk picture jbrooksuk  ·  6Comments

vpode picture vpode  ·  5Comments

alexfrancavilla picture alexfrancavilla  ·  9Comments

eduardokranz picture eduardokranz  ·  6Comments