From 4614bd86926517a99f668eb11c5144e98d3bec90 Mon Sep 17 00:00:00 2001 From: CMK Date: Sat, 19 Mar 2022 02:51:24 +0800 Subject: [PATCH] fix: textView break IME input issue. resolve #342 --- .../TableViewCell/ComposeStatusContentTableViewCell.swift | 5 ++++- ShareActionExtension/Scene/View/StatusEditorView.swift | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Mastodon/Scene/Compose/TableViewCell/ComposeStatusContentTableViewCell.swift b/Mastodon/Scene/Compose/TableViewCell/ComposeStatusContentTableViewCell.swift index c9c8fa4f..4c3d3716 100644 --- a/Mastodon/Scene/Compose/TableViewCell/ComposeStatusContentTableViewCell.swift +++ b/Mastodon/Scene/Compose/TableViewCell/ComposeStatusContentTableViewCell.swift @@ -161,7 +161,10 @@ extension ComposeStatusContentTableViewCell: UITextViewDelegate { logger.debug("\((#file as NSString).lastPathComponent, privacy: .public)[\(#line, privacy: .public)], \(#function, privacy: .public): text: \(textView.text ?? "")") guard textView === statusContentWarningEditorView.textView else { return } // replace line break with space - textView.text = textView.text.replacingOccurrences(of: "\n", with: " ") + // needs check input state to prevent break the IME + if textView.markedTextRange == nil { + textView.text = textView.text.replacingOccurrences(of: "\n", with: " ") + } contentWarningContent.send(textView.text) } diff --git a/ShareActionExtension/Scene/View/StatusEditorView.swift b/ShareActionExtension/Scene/View/StatusEditorView.swift index c945874e..595057fa 100644 --- a/ShareActionExtension/Scene/View/StatusEditorView.swift +++ b/ShareActionExtension/Scene/View/StatusEditorView.swift @@ -81,7 +81,10 @@ public struct StatusEditorView: UIViewRepresentable { } public func textViewDidChange(_ textView: UITextView) { - parent.string = textView.text + // prevent break IME input + if textView.markedTextRange == nil { + parent.string = textView.text + } } func updateLayout(width: CGFloat) {