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.

Fuzzy match, (potentially) expose matching algorithm, perf, styling, async API, etc.

See original GitHub issue

(I understand if this isn’t a big concern right now)

sou should probably match South Australia. Basically, fuzzy search that matches substrings (I keep forgetting the actual name of this), or conceptually adding .* after each letter in the search query regex.

API concerns

You can probably just expose a prop filterFunc f(query, potentialMatch): bool, with a sane default being the current internal filterOptions (maybe exported as ReactSelect.defaultFilter or simply used as the default value of filterFunc). Fuzzy match libraries are available everywhere, but you can also export a ReactSelect.fuzzyFilter, or not. This allows you to eliminate the library-specific matchPos prop in exchange for something agnostic, much more flexible (better user-made fuzzy match, match/do not match non-ascii chars, blabla) and equally clean.

Abstraction 1

(If the above one sounds realistic) Instead of the above, expose filterFunc as f(query): [String]. The function takes the query and returns a list of matches. This eliminates the seemingly necessary options props and gives you even more flexibility (dynamically changing list of options through if-elses in the callback). If you want to further reduce API surface, accept f(query): Promise [String], which is intended for async loading of options and/or match results. Kills asyncOptions.

Abstraction 2 (getting hardcore lol)

Built on top of either the original proposal or the previous one, if the latter makes sense. Say we use the latter. Change filterFunc to f(query): [ReactNode]. Solves #5. Solves potentially other styling issues that you’ll otherwise need to expose as additional options (and it’s hard to cover all the use-cases). Ultimate API would be f(query): Promise [ReactNode].

Perf concerns

Better perf tuning. The default is still the internal filterOptions. Except now the user will able to fine-tune it. E.g. smaller list? Use the best fuzzy match + frecency + levenshtein distance algorithm you got. Bigger list? Use a variation of default algorithm + caching.

Abstraction 1

Optional options caching is done by the user, by simply lifting the inline options list inside f into the upper scope (or use a transformer). Same for cached results. This isn’t important; just mentioning it for completeness.

Abstraction 2

Allows user to use either classes or inline styles. Latter for API niceness, former for historical reasons or perf.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:5
  • Comments:6

github_iconTop GitHub Comments

12reactions
bglusmancommented, May 11, 2018

For anyone else who comes across this issue and thinks its unresolved/not supported, it is actually perfectly doable today with the filterOptions parameter by passing a function…

I did fuzzy search with Fuse.io like this:

  filterOptions() {
    return function (options, filter) {
      var fuseOptions = {
        shouldSort: true,
        tokenize: true,
        threshold: 0.6,
        location: 0,
        distance: 100,
        maxPatternLength: 32,
        minMatchCharLength: 1,
        keys: [
          "label"
        ]
      };
      var fuse = new Fuse(options, fuseOptions);
      return fuse.search(filter);
    }
  }
...
render() {
    return (
            <Select
              name="form-field-name"
              value={ this.state.localId }
              onChange={ this.mkHandleChange(onAnswer()) }
              filterOptions={this.filterOptions()}
              options={ options }
              placeholder={placeholder}
            />
      );
  }
};
0reactions
jossmaccommented, Mar 17, 2020

Version 1 of react-select is no longer supported.

In the best interest of the community we’ve decided to spend the time we have available on the latest version.

We apologise for any inconvenience.

Please see:

  1. v1 to v2 upgrade guide
  2. v1 documentation and examples
Read more comments on GitHub >

github_iconTop Results From Across the Web

Fuzzy Match Tool | Alteryx Help
The Fuzzy Matching tool can be used to identify non-identical duplicates of a dataset by specifying match fields and similarity thresholds.
Read more >
Fuzzy Matching 101: Cleaning and Linking Messy Data
Fuzzy matching identifies the likelihood that two records are a true match based on whether they agree or disagree on the various identifiers....
Read more >
CUDA C++ Best Practices Guide
CUDA C++ Best Practices Guide. The programming guide to using the CUDA Toolkit to obtain the best performance from NVIDIA GPUs.
Read more >
Karate | Test Automation Made Simple.
Karate is the only open-source tool to combine API test-automation, mocks, performance-testing and even UI automation into a single, unified framework.
Read more >
Safari Technology Preview Release Notes - Apple Developer
commitStyles() not changing the style attribute for individual CSS ... so that the most commonly used property accounts for fuzzy-matching (252194@main) ...
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