tree-select icon indicating copy to clipboard operation
tree-select copied to clipboard

Search seems to be case sensitive

Open alexandermontgomery opened this issue 7 years ago • 6 comments

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?

alexandermontgomery avatar Oct 01 '17 00:10 alexandermontgomery

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;
};

wiziple avatar Oct 02 '17 23:10 wiziple

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 .

alexandermontgomery avatar Oct 02 '17 23:10 alexandermontgomery

can you tell me exactly treeSelectFilterTreeNode where to change in order to get case sensitive

sairam356 avatar May 14 '18 14:05 sairam356

how to overide clearly i am unable to override that

sairam356 avatar May 14 '18 14:05 sairam356

@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.

ollija avatar May 25 '18 09:05 ollija

Thanks for providing the solution. @ollija

sairam356 avatar May 28 '18 06:05 sairam356