linkedin / Spyglass

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

Fix issue with text insertion on some keyboards #106

Closed nhibner closed 4 years ago

nhibner commented 4 years ago

Certain keyboards treat deleting the last character in a mention (first if the cursor is moving right-to-left) as appending the previous word minus the last character. We are not sure why this behavior differs between keyboards, but we added some code to negate this behavior many years ago.

However, the code that negated this behavior had an unwanted side effect in that it also could impact text typed normally (without any mention spans).

To offer a better experience, this commit adds a check to ensure that the previous string actually contains a mention. If it contains a mention, we will maintain the previous custom behavior to address the issue. However, if there is no mention, we will not intercept the behavior. While this is not a fix for the underlying issue, it should improve the user experience for most cases where users were seeing this issue.

More details: https://github.com/linkedin/Spyglass/issues/105