Skip to content

Commit f01b010

Browse files
committed
Fix user mentions not working when commands are disabled
1 parent 546e6c7 commit f01b010

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

Sources/StreamChatSwiftUI/ChatChannel/Composer/MessageComposerView.swift

+21-14
Original file line numberDiff line numberDiff line change
@@ -192,20 +192,19 @@ public struct MessageComposerView<Factory: ViewFactory>: View, KeyboardReadable
192192
}
193193
}
194194
.overlay(
195-
viewModel.showCommandsOverlay ?
196-
factory.makeCommandsContainerView(
197-
suggestions: viewModel.suggestions,
198-
handleCommand: { commandInfo in
199-
viewModel.handleCommand(
200-
for: $viewModel.text,
201-
selectedRangeLocation: $viewModel.selectedRangeLocation,
202-
command: $viewModel.composerCommand,
203-
extraData: commandInfo
204-
)
205-
}
206-
)
207-
.offset(y: -composerHeight)
208-
.animation(nil) : nil,
195+
factory.makeCommandsContainerView(
196+
suggestions: suggestions,
197+
handleCommand: { commandInfo in
198+
viewModel.handleCommand(
199+
for: $viewModel.text,
200+
selectedRangeLocation: $viewModel.selectedRangeLocation,
201+
command: $viewModel.composerCommand,
202+
extraData: commandInfo
203+
)
204+
}
205+
)
206+
.offset(y: -composerHeight)
207+
.animation(nil),
209208
alignment: .bottom
210209
)
211210
.modifier(factory.makeComposerViewModifier())
@@ -224,6 +223,14 @@ public struct MessageComposerView<Factory: ViewFactory>: View, KeyboardReadable
224223
})
225224
.accessibilityElement(children: .contain)
226225
}
226+
227+
var suggestions: [String: Any] {
228+
var suggestions = viewModel.suggestions
229+
if !viewModel.showCommandsOverlay {
230+
suggestions.removeValue(forKey: "instantCommands")
231+
}
232+
return suggestions
233+
}
227234
}
228235

229236
/// View for the composer's input (text and media).

0 commit comments

Comments
 (0)