webscopeio / react-textarea-autocomplete

📝 React component implements configurable GitHub's like textarea autocomplete.
MIT License
454 stars 80 forks source link

Feature: add onSelect callback #163

Closed O4epegb closed 5 years ago

O4epegb commented 5 years ago

Is it a good idea to add something like onSelect callback?

My use case is that I want to send some analytics about what users pick in autocomplete. It is quite hard to parse it from raw text, and result is not guarantied, because user could just copy paste text without selecting it from autocomplete dropdown. Maybe there are other cases, for example, you may want to show something if user pick some special item in the list, something like that.

I am not sure about api of this callback, maybe just pass an item with trigger string like that:

{
  triggerString: '@',
  item: {item from dataProvider}
}
jukben commented 5 years ago

Yeah, I think this use-case makes sense! I also like the API. The prop could be name something like onItemSelected what do you think?

O4epegb commented 5 years ago

Wow, thank you very much @jukben, awesome! Was very busy for quite a while, could not find the time to implement it

jukben commented 5 years ago

Give it a try! I hope it's gonna be OK. 🚀