Skip to content

Show typing suggestions for text with whitespace #781

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Add `Fonts.title2` for supporting markdown headers [#757](https://github.com/GetStream/stream-chat-swiftui/pull/757)
- Add `resignsFirstResponderOnScrollDown` to `MessageListConfig` [#769](https://github.com/GetStream/stream-chat-swiftui/pull/769)
- 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)
### 🐞 Fixed
- Show typing suggestions for names containing whitespace [#781](https://github.com/GetStream/stream-chat-swiftui/pull/781)
### 🔄 Changed
- 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)
- Customizing the message avatar view is reflected in all views that use it [#772](https://github.com/GetStream/stream-chat-swiftui/pull/772)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,9 @@ public struct TypingSuggester {
return nil
}

// Fetch the suggestion text. The suggestions can't have spaces.
// valid example: "@luke_skywa..."
// invalid example: "@luke skywa..."
// Fetch the suggestion text.
let suggestionLocation = NSRange(location: suggestionStart, length: suggestionEnd - suggestionStart)
let suggestionText = textString.substring(with: suggestionLocation)
guard !suggestionText.contains(" ") else {
return nil
}
Comment on lines -123 to -125
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't figure out why this was added here. Otherwise the implementation is same as in the UIKit.


// A minimum number of characters can be provided to only show
// suggestions after the customer has input enough characters.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ class TypingSuggester_Tests: XCTestCase {
XCTAssert(suggestion?.locationRange == NSRange(location: 1, length: 2))
}

func test_typingSuggester_notFoundEmptySpace() {
func test_typingSuggester_emptySpaceAllowed() {
// Given
let options = TypingSuggestionOptions(symbol: "@")
let typingSuggester = TypingSuggester(options: options)
let string = "@M art"
let caretLocation = 3
let string = "@Han Solo"
let caretLocation = 6

// When
let suggestion = typingSuggester.typingSuggestion(
Expand All @@ -76,7 +76,8 @@ class TypingSuggester_Tests: XCTestCase {
)

// Then
XCTAssert(suggestion == nil)
XCTAssertEqual("Han S", suggestion?.text)
XCTAssertEqual(NSRange(location: 1, length: 5), suggestion?.locationRange)
}

func test_typingSuggester_notFoundNotOnStart() {
Expand Down
Loading