If you search for a string with white space, it will save the string WITH white space into this.searchString, but it'll search for that string WITHOUT white space, because
searchString = searchString.replace(/^\s+|\.{2,}\/|\s+$/g, '');
so when it gets the results and is about to show them, it compares the 2 strings (which are different):
if (db.searchString == searchString) {
db.owner.found(matches);
}
The fix couldn't be easier: save the string AFTER trimming it, because that's the only string actually used anywhere.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | drupal-autocomplete-white-space-bug-2692099-2.patch | 722 bytes | rudiedirkx |
Comments
Comment #2
rudiedirkx commentedVery simple patch.
Comment #3
poker10 commentedUnfortunatelly I am not able to reproduce the issue. The regexp seems to be removing only starting and trailing whitespaces. If I search for a string with whitespace in it (like "test test"), it is found correctly (the middle whitespace is not removed). Can you please provide more information what is wrong here?
I have found one similar issue: #1221612: Autocomplete with trailing space, but according to the issue summary this does not seems to be the same problem.
Thanks!