Skip to content

Suggestion: enter minimum number of characters before searching #161

@wildhart

Description

@wildhart

I have another suggestion.

With a very long list of options (or with an Ajax call), and with only one or two characters entered the filtered results can still be long and meaningless.

I have managed to delay the search until you enter at least 3 characters by simulating Ajax:

<treeselect v-model="mapZone" @input="changeMap" :open-on-click="false"
    async :load-options="searchMapZone" retry-text=""
    clear-on-select placeholder="Change Map or Zone..."/>
</treeselect>
searchMapZone: function({action, searchQuery, callback}) {
    if (searchQuery.length<3) return callback('Please keep typing...', []);
    searchQuery = searchQuery.toLowerCase();
    callback(null, this.mapsZones.filter(function(item) {
        return item.label.toLowerCase().indexOf(searchQuery)!=-1;
    }));
},

It would be nice to have a build-in prop :min-chars="3" to require a minimum number of characters before the list is searched/displayed.

Thank you for making this awesome module available!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions