From f1b5870a055f4c0f6e7ca5dc2b286a34f7c4e829 Mon Sep 17 00:00:00 2001 From: Gian <47775302+gpunto@users.noreply.github.com> Date: Mon, 29 Jun 2026 13:26:28 +0200 Subject: [PATCH] ui-common: Show mention suggestions after non-alphanumeric dividers --- .../feature/messages/composer/typing/TypingSuggester.kt | 9 +++++---- .../messages/composer/typing/TypingSuggesterTest.kt | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/messages/composer/typing/TypingSuggester.kt b/stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/messages/composer/typing/TypingSuggester.kt index 02c7f8681ee..d0b1a573077 100644 --- a/stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/messages/composer/typing/TypingSuggester.kt +++ b/stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/messages/composer/typing/TypingSuggester.kt @@ -38,10 +38,11 @@ internal class TypingSuggester(private val options: TypingSuggestionOptions) { return null } - // Only show typing suggestions after a space, or at the start of the input - // valid examples: "@user", "Hello @user" - // invalid examples: "Hello@user" - val isValidPosition = firstSymbolBeforeCaret == 0 || text[firstSymbolBeforeCaret - 1].isWhitespace() + // The symbol must not be glued to a letter or digit. + // valid: "@user", "Hello @user", "@user,@user2" + // invalid: "Hello@user" + val charBeforeSymbol = text.getOrNull(firstSymbolBeforeCaret - 1) + val isValidPosition = charBeforeSymbol?.isLetterOrDigit() != true if (!isValidPosition) { return null } diff --git a/stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/feature/messages/composer/typing/TypingSuggesterTest.kt b/stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/feature/messages/composer/typing/TypingSuggesterTest.kt index bf4b278b15c..c09cd166840 100644 --- a/stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/feature/messages/composer/typing/TypingSuggesterTest.kt +++ b/stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/feature/messages/composer/typing/TypingSuggesterTest.kt @@ -45,6 +45,10 @@ internal class TypingSuggesterTest { Arguments.of("@ ", null), Arguments.of("@ john", null), Arguments.of("Hello@john", null), + Arguments.of("@john,@jane", TypingSuggestion("jane", 7 until 11)), + Arguments.of("@john, @jane", TypingSuggestion("jane", 8 until 12)), + Arguments.of("(@john", TypingSuggestion("john", 2 until 6)), + Arguments.of("john@example.com", null), ) } }