Skip to content

Commit 4def393

Browse files
Fixed bug with scrolling of text input field (#20)
1 parent b2ef1bc commit 4def393

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

Sources/StreamChatSwiftUI/ChatChannel/Composer/MessageComposerView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public struct ComposerInputView<Factory: ViewFactory>: View {
188188

189189
var textFieldHeight: CGFloat {
190190
let minHeight: CGFloat = 34
191-
let maxHeight: CGFloat = 70
191+
let maxHeight: CGFloat = 76
192192

193193
if textHeight < minHeight {
194194
return minHeight

Sources/StreamChatSwiftUI/Utils/Common/InputTextView.swift

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class InputTextView: UITextView {
2424
/// The maximum height of the text view.
2525
/// When the content in the text view is greater than this height, scrolling will be enabled and the text view's height will be restricted to this value
2626
open var maximumHeight: CGFloat {
27-
70.0
27+
76.0
2828
}
2929

3030
override open func didMoveToSuperview() {
@@ -71,7 +71,7 @@ class InputTextView: UITextView {
7171

7272
heightConstraint = heightAnchor.constraint(equalToConstant: minimumHeight)
7373
heightConstraint?.isActive = true
74-
isScrollEnabled = true
74+
isScrollEnabled = false
7575
}
7676

7777
/// Sets the given text in the current caret position.
@@ -109,13 +109,7 @@ class InputTextView: UITextView {
109109
}
110110

111111
heightConstraint?.constant = heightToSet
112+
isScrollEnabled = heightToSet > minimumHeight
112113
layoutIfNeeded()
113-
114-
// This is due to bug in UITextView where the scroll sometimes disables
115-
// when a very long text is pasted in it.
116-
// Doing this ensures that it doesn't happen
117-
// Reference: https://stackoverflow.com/a/33194525/3825788
118-
isScrollEnabled = false
119-
isScrollEnabled = true
120114
}
121115
}

0 commit comments

Comments
 (0)