react-filtered-multiselect icon indicating copy to clipboard operation
react-filtered-multiselect copied to clipboard

filter

Open srconklin opened this issue 8 years ago • 1 comments

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

srconklin avatar Jan 17 '16 18:01 srconklin

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.

insin avatar May 31 '17 09:05 insin