tree-select
tree-select copied to clipboard
Search seems to be case sensitive
If I have a node in the tree called 'Alpha' then if I search 'alpha' there is no result. Any ideas how to make the search case insensitive?
You can override filterTreeNode something like this.
export const treeSelectFilterTreeNode = (input, treeNode) => {
const compare1 = treeNode.props.title.toLowerCase();
const compare2 = input.toLowerCase();
return compare1.indexOf(compare2) >= 0;
};
Perfect. Thank you!
On Mon, Oct 2, 2017 at 7:56 PM, Daewoong Moon [email protected] wrote:
You can override filterTreeNode something like this.
export const treeSelectFilterTreeNode = (input, treeNode) => { const compare1 = treeNode.props.title.toLowerCase(); const compare2 = input.toLowerCase(); return compare1.indexOf(compare2) >= 0; };
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/react-component/tree-select/issues/76#issuecomment-333698584, or mute the thread https://github.com/notifications/unsubscribe-auth/AA_ibl58-0B0yQuV_uyFUSPBX4rABwCxks5soXgngaJpZM4PpvOu .
can you tell me exactly treeSelectFilterTreeNode where to change in order to get case sensitive
how to overide clearly i am unable to override that
@sairam356 just pass wiziple's solution as filterTreeNode
-attribute:
const treeSelectFilterTreeNode = (input, treeNode) => {
const compare1 = treeNode.props.title.toLowerCase();
const compare2 = input.toLowerCase();
return compare1.indexOf(compare2) >= 0;
};
...
<TreeSelect
filterTreeNode={treeSelectFilterTreeNode}
...
/>
However, I think the proper solution would be that the filter was made case-insensitive by default, and it could be set strict by some boolean attribute.
Thanks for providing the solution. @ollija