Closed jukben closed 5 years ago
@guidogast
I dug more into it and, actually, I'm not sure how to solve it. It's not a bug but more like feature. Your trigger is [
and you are returning [something
that means that the trigger is still active thus the autocomplete is shown. Not sure how easily distinguish that you are satisfied with the selection and you don't wanna show the autocomplete anymore.
Fist thought I had was that I can track "dirtiness" of the input. e.g once you select the item I can hide the autocomplete unless you start typing (without space) more, or unless you start with deleting the current text. Both of this would lead autocomplete to open because the trigger char would be still the [
. Does it make a sense? I'm not sure if this solves the issue for you.
@jukben Thanks for checking the issue. Logic that makes sense to me would be something similar to Visual Studio (Code):
Once you press a trigger key, it should show the autocomplete. When you press "Enter/Return" or "Tab", the selected value will be inserted and the autocomplete should disappear. Don't search for triggers after it's been inserted (Unless you retrigger it via another default autocomplete trigger (Ctrl + Space would be awesome))
This way, the issues that I'm experiencing would be solved and it would make this plugin unbelievably powerful 😄.
Is this use case clear for you?
Thanks for the input. Makes sense. I'll try to do some exploration. Stay tuned. 🤓
I'll take Code as an example, good idea!
Hey, it would be wonderful @guidogast if you can try this branch https://github.com/webscopeio/react-textarea-autocomplete/pull/107 I'd appreciate your feedback! 🙏
Edit: This is sneak peek from the playground:
Closed in #107
100
@guidogast