linkedin / Spyglass

A library for mentions on Android
Apache License 2.0
387 stars 128 forks source link

No TokenReceiver callback if explicit char is deleted #112

Open zoubarry opened 3 years ago

zoubarry commented 3 years ago

If explicit char is set to be e.g. "@" Whenever user types "@", token receiver will get a callback with queryToken("@") But if user deletes "@", there is no callback at all, ls there a way to also trigger the callback on deletion of explicit chars? Thanks

zoubarry commented 3 years ago

it might not be an issue, just interested to know if this is possible at all?

nhibner commented 3 years ago

I don't think the library supports that out-of-the-box. If it's something that would be useful, I'd be open to adding that functionality. There are some edge cases that we would need to think about (e.g. what if I typed @Alice @Bob, selected all the text, and deleted it all at once -- would you expect one callback or two?).

For what it's worth, you could also implement this functionality with a standard TextWatcher.

bob commented 3 years ago

Hmm, what if I typed @nhibner

nhibner commented 3 years ago

Whoops, sorry about that! I forgot to escape that sample text, that's my bad.

zoubarry commented 3 years ago

The original intention for this is to hide the suggestion list when deleting e.g. "@". However, it's already supported out of the box via SuggestionVisibilityMgr.displaySuggestions, So it is not a problem for my use case at this point.