Skip to content

Commit

Permalink
Fix issue where text view is not scrollable when pasting a long text (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ipavlidakis committed Nov 14, 2023
1 parent c981c5e commit ff66af6
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,17 @@ open class InputTextView: UITextView, AppearanceProvider {

@objc open func handleTextChange() {
placeholderLabel.isHidden = !text.isEmpty
setNeedsDisplay()
setNeedsLayout()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in
// This is due to bug in UITextView where the scroll sometimes disables
// when a very long text is pasted in it.
// Doing this ensures that it doesn't happen
// Reference: https://stackoverflow.com/a/62386088/5493299

self?.isScrollEnabled = false
self?.layoutIfNeeded()
self?.isScrollEnabled = true
}
}

@objc func textDidEndEditing(notification: Notification) {
Expand Down

0 comments on commit ff66af6

Please sign in to comment.