insin / react-filtered-multiselect

Filtered multi-select React component

Home Page:http://insin.github.io/react-filtered-multiselect

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

filter

srconklin opened this issue · comments

Hi
Is there a way to make the filter only math the characters at the beginning of the option text values?

Not currently, but we could add a prop which takes a test function which would receive the current filter and the item being tested:

The current implementation is effectively this:

function contains(filter, optionText) {
  return optionText.toUpperCase().indexOf(filter.toUpperCase()) !== -1
}

What you're asking for would be:

function startsWith(filter, optionText) {
  return optionText.toUpperCase().indexOf(filter.toUpperCase()) === 0
}

We could also export a basic selection of test functions so people don't have to write their own.