webscopeio / react-textarea-autocomplete

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

Autocomplete is not triggered sometimes #117

Closed O4epegb closed 5 years ago

O4epegb commented 5 years ago

Autocomplete is not triggered sometimes. I could not understand why yet, but you can reproduce it here https://codesandbox.io/s/30mrxq107m

Steps: 1) Type ":" to trigger autocompete, then close it by "Esc" key press and press "Backspace" or "Delete" to remove text 2) Type some text, like "asd", then press "Shift+Enter" to make new line, repeat it 3 times 3) Then press "Up" key to move one line upward 4) Type ":" again, nothing will happen

Strange thing, don't know why it is happening yet

jukben commented 5 years ago

Hey, you are right, it's definitely something regarding the new behavior https://github.com/webscopeio/react-textarea-autocomplete/pull/107/files. I guess that this.lastTrigger should have been cleared in that case. However, I have to take a deeper look.

Basically, you can just write "something", then move with the cursor by arrows backward and observe the issue, correct?

O4epegb commented 5 years ago

Basically, you can just write "something", then move with the cursor by arrows backward and observe the issue, correct?

Yep, that's definitely easier way to reproduce! :)

jukben commented 5 years ago

I have and idea to watch the caret change and then call cleanLastTrigger(). I'll take a look on it durring next few days. Thanks for the issue 🙏

jukben commented 5 years ago

Hey @O4epegb! Could you please check 4.2.0? It should be fixed! 🙏

O4epegb commented 5 years ago

Working great, thank you! Switched from v2 to v4 in production today.

Found only one minor bug, not sure if it is worth to fix, but here it is:

1) Type anything -> "something" 2) Trigger autocomplete -> "something @" 3) Then move caret back with arrows and trigger again -> "some@thing @" 4) Select autocomplete value 5) It will correctly show popup, but after you select value it will show it again for first trigger

Very rare edge case I suppose, but if it is not hard to fix would be cool)