• Try your search with “as” then space. You’ll see weird results.
    Suggests will be like:

    ass="iss_match">Assets

    and the html:

    <li class="iss-result">
    <span cl<span="" class="iss_match">as</span>s="iss_match"><span class="iss_match">As</span>sets
    ...
    </li>

    I’ve figured out that “as”, “is”, “ss” breaks the template. But there may be more. With every next space the template goes crazy.
    If minchars option in jquery.suggest.js (btw, let cache plugins minify assets) is changed from 2 to 3, the error is gone.

    https://ww.wp.xz.cn/plugins/instant-search-suggest/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Scott (@scottsweb)

    (@scottsweb)

    Can you provide a link to the site where this happens? ‘is’ and ‘as’ are not particularly good search terms to be testing with as many posts will contain those – the title and post content are searched for suggestions.

    It may be that I need to implement a list of stop words that are removed from searches.

    Thread Starter John_G

    (@john_g)

    For now I don’t have live site. But I’ll add remark below the search field:
    “Dear users don’t type [as,is,ss] and after [Space,Ctrl,Shift or any other white space symbol], because this terms are not particularly good for searching.”
    I think you should find the logic flaw instead of implementing some kind of stop lists. Any of this combinations of characters may be the thing the user searches for (for instance, a model of a device).

    Also, I can restrict the plugin to search only the title (for example).
    Suggest part of your plugin must provide the visual assistance for the data it somehow gets from the response without no assumptions that some words are “so common” that I (plugin) will display them out of square.

    Thread Starter John_G

    (@john_g)

    So, I don’t know if is it you modified some plugin jquery.suggest.js (because there is no credentials in minified file) or is it solely yours. But the logic of highlighting of substring is bullshit. Look:
    Let’s assume we have some title “The classy glass” (I think you already spotted the pitfall).
    1. User enters “class” + space
    2. Suggest suggest “The classy glass”
    3. The highlighted part of the suggest is the html:

    The <span class="iss_match">class</span>y glass

    4. Then this html string is cached with all the tags.
    5. User presses any white space characters.
    6. The plugin again replaces all class substring with the same template:

    The <span !class!="iss_match">class</span>y glass
    The <span !<span class="iss_match">class</span>!="iss_match">class</span>y glass

    Note the substrings between exclamation marks.
    So, any string that is a substring of <span class="iss_match">$&</span> gets screwed.

    1. I fixed this issue by disabling caching of the rendered items of the suggest list. Somehow they are cached with html markup (stupid).

    file: jquery.suggest.js
    //c.addToCache(b, a.length)

    Someone should fix the logic of caching. Who is the author of the jquery.suggest ?

    2. Also I modified the highlighting by modifying the

    file: jquery.suggest.js
    
    addMatchClass: function(a, b) {
      var REGEX = '(' +
        this.$input.val().trim().split(/\s+/).join('|') +
        ')';
    
      return a.replace(
        new RegExp( REGEX , "ig"),
        '<span class="' + this.options.matchClass + '">$&</span>')
    },

    This is somewhat of upgrade. Now all the words from the input field get highlighted independently.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘as as ass’ is closed to new replies.