react-autocomplete
react-autocomplete copied to clipboard
[added] optional custom function to compare input value to list option values
fixes #239, #266
Allows us to specify a custom comparison function to evaluate matches. In the same way the flexibility is provided to fully control the options list via your own code/logic, it would be good to be able to do the same for highlight matches. The issues above where users would like to check for string contains raher than startsWith will be able to do something like the following:
valueItemComparison={(optionItemValue, inputValue) => {
return optionItemValue.toLowerCase().includes(inputValue.toLowerCase())
}}
This is a backwards compatible change, if the prop is not specified, then the old comparison logic using indexOf() is the default.
Possible improvements:
- naming of the comparison function and its input variables (a minor point, but I don't think they fit with the rest of the libs naming style)