8000 Show typing suggestions for text with whitespace (mentions with full … · GetStream/stream-chat-swiftui@e6e2fc0 · GitHub
[go: up one dir, main page]

Skip to content

Commit e6e2fc0

Browse files
authored
Show typing suggestions for text with whitespace (mentions with full name) (#781)
1 parent 9e49e0f commit e6e2fc0

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
88
- Add `Fonts.title2` for supporting markdown headers [#757](https://github.com/GetStream/stream-chat-swiftui/pull/757)
99
- Add `resignsFirstResponderOnScrollDown` to `MessageListConfig` [#769](https://github.com/GetStream/stream-chat-swiftui/pull/769)
1010
- Show auto-translated message translations ([learn more](https://getstream.io/chat/docs/ios-swift/translation/#enabling-automatic-translation)) [#776](https://github.com/GetStream/stream-chat-swiftui/pull/776)
11+
### 🐞 Fixed
12+
- Show typing suggestions for names containing whitespace [#781](https://github.com/GetStream/stream-chat-swiftui/pull/781)
1113
### 🔄 Changed
1214
- Uploading a HEIC photo from the library is now converted to JPEG for better compatibility [#767](https://github.com/GetStream/stream-chat-swiftui/pull/767)
1315
- Customizing the message avatar view is reflected in all views that use it [#772](https://github.com/GetStream/stream-chat-swiftui/pull/772)
10000

Sources/StreamChatSwiftUI/ChatChannel/Composer/Suggestions/TypingSuggester.swift

+1-6
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,9 @@ public struct TypingSuggester {
115115
return nil
116116
}
117117

118-
// Fetch the suggestion text. The suggestions can't have spaces.
119-
// valid example: "@luke_skywa..."
120-
// invalid example: "@luke skywa..."
118+
// Fetch the suggestion text.
121119
let suggestionLocation = NSRange(location: suggestionStart, length: suggestionEnd - suggestionStart)
122120
let suggestionText = textString.substring(with: suggestionLocation)
123-
guard !suggestionText.contains(" ") else {
124-
return nil
125-
}
126121

127122
// A minimum number of characters can be provided to only show
128123
// suggestions after the customer has input enough characters.

StreamChatSwiftUITests/Tests/ChatChannel/Suggestions/TypingSuggester_Tests.swift

+5-4
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ class TypingSuggester_Tests: XCTestCase {
6262
XCTAssert(suggestion?.locationRange == NSRange(location: 1, length: 2))
6363
}
6464

65-
func test_typingSuggester_notFoundEmptySpace() {
65+
func test_typingSuggester_emptySpaceAllowed() {
6666
// Given
6767
let options = TypingSuggestionOptions(symbol: "@")
6868
let typingSuggester = TypingSuggester(options: options)
69-
let string = "@M art"
70-
let caretLocation = 3
69+
let string = "@Han Solo"
70+
let caretLocation = 6
7171

7272
// When
7373
let suggestion = typingSuggester.typingSuggestion(
@@ -76,7 +76,8 @@ class TypingSuggester_Tests: XCTestCase {
7676
)
7777

7878
// Then
79-
XCTAssert(suggestion == nil)
79+
XCTAssertEqual("Han S", suggestion?.text)
80+
XCTAssertEqual(NSRange(location: 1, length: 5), suggestion?.locationRange)
8081
}
8182

8283
func test_typingSuggester_notFoundNotOnStart() {

0 commit comments

Comments
 (0)
0