Skip to content

Commit 015b4b8

Browse files
fixed a bug with autocompleting commands text
1 parent 3362e3e commit 015b4b8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Sources/StreamChatSwiftUI/ChatChannel/Composer/MessageComposerViewModel.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,12 @@ public class MessageComposerViewModel: ObservableObject {
9696
didSet {
9797
if oldValue?.id != composerCommand?.id &&
9898
composerCommand?.displayInfo?.isInstant == true {
99-
text = ""
99+
// This is needed because of autocompleting text from the keyboard.
100+
// The update of the text is done in the next cycle, so it overrides
101+
// the setting of this value to empty string.
102+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) { [weak self] in
103+
self?.text = ""
104+
}
100105
}
101106
if oldValue != nil && composerCommand == nil {
102107
pickerTypeState = .expanded(.none)

0 commit comments

Comments
 (0)