webscopeio / react-textarea-autocomplete

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

Never decrease index in listener #126

Closed JelteF closed 5 years ago

JelteF commented 5 years ago

Doing the following will break otherwise, f2 will be deleted by the add of f3:

let index = Listener.add(KEY_CODES.ENTER, f1)
Listener.add(KEY_CODES.ENTER, f2)
Listener.remove(index)
Listener.add(KEY_CODES.ENTER, f3)
jukben commented 5 years ago

That makes sense! Could you please guide me how have you discovered the issue? There has to be also check in this.f if the listener exists or it was removed, going to push it.

Thanks for your contribution!

jukben commented 5 years ago

(bot)

Hey! Thank you so much for your PR! I can see that everything is green 👏.

Here is the playground for this revision 🚀

I hope everything is fine! ❤️

JelteF commented 5 years ago

You were right about that my fixed missed the iteration part. The way I found it was that the events just stopped working after a long session with some navigation steps in between. And I think this was the reason for that.

jukben commented 5 years ago

Nice, Object.values are even better 👍 Thanks I'm gonna deploy it with fix from #124

jukben commented 5 years ago

Deployed as 4.2.3! 🚀