Skip to content

Commit eb3a3c5

Browse files
Fixed cursor jumps around in the composer when @ mentioning
1 parent 58bca71 commit eb3a3c5

File tree

7 files changed

+52
-0
lines changed

7 files changed

+52
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1212
- Channel actions popup wrong appearance using a custom `NavigationView`
1313
- Channel list automatic channel selection disabled for compact iPad screen size
1414
- Mentions of users available in a new line
15+
- Cursor jumps around in the composer when @ mentioning
1516

1617
# [4.28.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.28.0)
1718
_February 28, 2023_

Sources/StreamChatSwiftUI/ChatChannel/Composer/ComposerTextInputView.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ struct ComposerTextInputView: UIViewRepresentable {
4141
if uiView.markedTextRange == nil {
4242
var shouldAnimate = false
4343
if uiView.text != text {
44+
let previousLocation = selectedRangeLocation
4445
shouldAnimate = uiView.shouldAnimate(text)
4546
uiView.text = text
47+
selectedRangeLocation = previousLocation
4648
}
4749
uiView.selectedRange.location = selectedRangeLocation
4850
uiView.isEditable = editable

StreamChatSwiftUI.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@
199199
846608E5278C865200D3D7B3 /* TypingIndicatorPlacement.swift in Sources */ = {isa = PBXBuildFile; fileRef = 846608E4278C865200D3D7B3 /* TypingIndicatorPlacement.swift */; };
200200
846608E7278C95E700D3D7B3 /* ChatChannelExtensions_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 846608E6278C95E700D3D7B3 /* ChatChannelExtensions_Tests.swift */; };
201201
846608E9278C98CB00D3D7B3 /* TypingIndicatorView_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 846608E8278C98CB00D3D7B3 /* TypingIndicatorView_Tests.swift */; };
202+
8469592F29BB235400134EA0 /* LazyImageExtensions_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8469592E29BB235400134EA0 /* LazyImageExtensions_Tests.swift */; };
202203
846AD4D0284F89B10074A0DD /* StreamChatTestMockServer in Frameworks */ = {isa = PBXBuildFile; productRef = 846AD4CF284F89B10074A0DD /* StreamChatTestMockServer */; };
203204
846AD4D2284F89B10074A0DD /* StreamChatTestTools in Frameworks */ = {isa = PBXBuildFile; productRef = 846AD4D1284F89B10074A0DD /* StreamChatTestTools */; };
204205
846AD4D4284F95710074A0DD /* CustomChannelHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 846AD4D3284F95710074A0DD /* CustomChannelHeader.swift */; };
@@ -609,6 +610,7 @@
609610
846608E4278C865200D3D7B3 /* TypingIndicatorPlacement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TypingIndicatorPlacement.swift; sourceTree = "<group>"; };
610611
846608E6278C95E700D3D7B3 /* ChatChannelExtensions_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatChannelExtensions_Tests.swift; sourceTree = "<group>"; };
611612
846608E8278C98CB00D3D7B3 /* TypingIndicatorView_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TypingIndicatorView_Tests.swift; sourceTree = "<group>"; };
613+
8469592E29BB235400134EA0 /* LazyImageExtensions_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LazyImageExtensions_Tests.swift; sourceTree = "<group>"; };
612614
846AD4D3284F95710074A0DD /* CustomChannelHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomChannelHeader.swift; sourceTree = "<group>"; };
613615
846B15F32817E7630017F7A1 /* ChatChannelInfoViewModel_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatChannelInfoViewModel_Tests.swift; sourceTree = "<group>"; };
614616
846D6563279FF0800094B36E /* ReactionUserView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReactionUserView.swift; sourceTree = "<group>"; };
@@ -1466,6 +1468,7 @@
14661468
84D419B928EAD20C00F574F9 /* ChatMessageBubbles_Tests.swift */,
14671469
84E1D8252976B3F100060491 /* MessageViewMultiRowReactions_Tests.swift */,
14681470
84AA6EA92987EE51005732EF /* MessageListViewNewMessages_Tests.swift */,
1471+
8469592E29BB235400134EA0 /* LazyImageExtensions_Tests.swift */,
14691472
);
14701473
path = ChatChannel;
14711474
sourceTree = "<group>";
@@ -2104,6 +2107,7 @@
21042107
84E04794284A444E00BAFA17 /* APIClient_Mock.swift in Sources */,
21052108
844D1D682851DE58000CCCB9 /* ChannelControllerFactory_Tests.swift in Sources */,
21062109
84CC3731290B095E00689B73 /* ChatChannelDataSource_Tests.swift in Sources */,
2110+
8469592F29BB235400134EA0 /* LazyImageExtensions_Tests.swift in Sources */,
21072111
84B439E127C6B2F100C04C99 /* MessageCachingUtils_Tests.swift in Sources */,
21082112
8423C346277D9BFF0092DCF1 /* TestCommandsConfig.swift in Sources */,
21092113
84B2B5D82819778D00479CEE /* FileAttachmentsViewModel_Tests.swift in Sources */,
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// Copyright © 2023 Stream.io Inc. All rights reserved.
3+
//
4+
5+
import NukeUI
6+
import SnapshotTesting
7+
@testable import StreamChat
8+
@testable import StreamChatSwiftUI
9+
import SwiftUI
10+
import XCTest
11+
12+
@MainActor
13+
final class LazyImageExtensions_Tests: StreamChatTestCase {
14+
15+
func test_imageURL_empty() {
16+
// Given
17+
let lazyImageView = LazyImage(imageURL: nil)
18+
.applyDefaultSize()
19+
20+
// Then
21+
assertSnapshot(matching: lazyImageView, as: .image)
22+
}
23+
24+
func test_imageURL_nonEmpty() {
25+
// Given
26+
let lazyImageView = LazyImage(
27+
imageURL: URL(string: "https://vignette.wikia.nocookie.net/starwars/images/2/20/LukeTLJ.jpg")
28+
)
29+
.applyDefaultSize()
30+
31+
// Then
32+
assertSnapshot(matching: lazyImageView, as: .image)
33+
}
34+
35+
func test_imageRequest_emptyURL() {
36+
// Given
37+
let lazyImageView = LazyImage(imageURL: nil) { _ in
38+
ProgressView()
39+
}
40+
.applyDefaultSize()
41+
42+
// Then
43+
assertSnapshot(matching: lazyImageView, as: .image)
44+
}
45+
}
46.5 KB
Loading
48.5 KB
Loading
48.5 KB
Loading

0 commit comments

Comments
 (0)