question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

searchFloor and search text filter interaction

See original GitHub issue

I’ve recently started a new project with Choices (latest version), and I’m noticing a strange behaviour in filtering.

With a near-default setup:

image

I’m getting these two sets of behaviour on standard single-choice select boxes:

image

image

I managed to narrow it down to the minimum character - based on the above two outcomes (and the fact that other random strings such as zz don’t show any results), it appears to only be searching on the characters above the minimum search length (i.e. + and a)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

6reactions
ojensen5115commented, May 17, 2017

@lewishowles Choices uses fuse, a fuzzy-matching string search which allows for typos. By default, the fuzziness is very lenient, which can lead to confusing results. It sounds like what you’re looking for is exact string matching.

If you’re looking for exact matching from the beginning of the string, instruct fuse to accept only exact matches by giving it a fuzziness threshold of 0:

var choices = new Choices('.form__select', {
    shouldSort : false,
    fuseOptions: {
        threshold: 0
    }
});

If instead you’re looking for exact matching but from anywhere in the string, AFAIK fuse doesn’t support this directly but you can hack it. Fuse calculates the fuziness of a result as a function of correctness and distance (i.e. offset), so you can tell it to accept a low fuziness threshold and give it a high distance parameter, which causes distance to be weighted very lightly:

var choices = new Choices('.form__select', {
    shouldSort : false,
    fuseOptions: {
        threshold: 0.1,
        distance: 1000
    }
});

Note that if your fields are very long, you may have to tweak the above parameters somewhat.

1reaction
DanielRufcommented, Nov 27, 2017

The solution from https://github.com/jshjohnson/Choices/issues/135#issuecomment-302124496 works. Thanks. Would be good to have this as an example.

Read more comments on GitHub >

github_iconTop Results From Across the Web

searchFloor and search text filter interaction #135 - GitHub
I've recently started a new project with Choices (latest version), and I'm noticing a strange behaviour in filtering.
Read more >
Search filter by entering text and select all afterwards - Possible?
Click Select all under the list and enter your search text in the search bar ... It should be possible to select only...
Read more >
Power BI Custom Visuals - Text Filter - YouTube
Try our On-Demand Training Platform for free! Get your 7-day trial here: http://success.pragmaticworks.com/learn-power-biIn this module, ...
Read more >
Using the Text Filter Node - SAS Help Center
In the Interactive Filter Viewer, type software in the Search text box, and click Apply. Interactive Filter Viewer. The Documents table provides ...
Read more >
overture albuquerque floor plans
Explore our luxury 55+ apartments in Albuquerque today to find your next home. ... View Floorplans View Interactive Map Search Filter Move-in Date...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found