yury-dymov / react-autocomplete-input

Autocomplete input field for React
https://yury-dymov.github.io/react-autocomplete-input/
MIT License
199 stars 65 forks source link

Option to prevent triggering inside the word #127

Closed karpov-sv closed 9 months ago

karpov-sv commented 10 months ago

Originally part of #123. The feature is disabled by default. To enable, set triggerInsideWord=false, then it will not trigger on parts of longer words (e.g. subclass will not trigger the options defined for class)

yury-dymov commented 10 months ago

This is not needed unless I am missing something. Same can be achieved either with matchAny prop or by providing a custom matching regex expression ([a-zA-Z0-9_\-]+$ most likely)

karpov-sv commented 10 months ago

The patch is for trigger detection, not options contents - so matchAny and regex both are not applicable here. The problem is when you declare e.g. class= as your trigger (to autocomplete the actual value of the class), and then type subclass= - it will be triggered by default, which is not a desirable behaviour in some cases.

yury-dymov commented 9 months ago

Can we use a triggerMatchWholeWord prop name, which aligns well with common language used in IDEs? May I also ask to extend documentation with an example above? This would be sufficient for me to merge this PR

karpov-sv commented 9 months ago

Also done!