diff --git a/src/components/views/rooms/MessageComposer.tsx b/src/components/views/rooms/MessageComposer.tsx index 2d5f9cc99c..1e8276ba8f 100644 --- a/src/components/views/rooms/MessageComposer.tsx +++ b/src/components/views/rooms/MessageComposer.tsx @@ -336,7 +336,10 @@ export class MessageComposer extends React.Component { const { permalinkCreator, relation, replyToEvent } = this.props; const composerContent = this.state.composerContent; this.setState({ composerContent: "", initialComposerContent: "" }); - dis.dispatch({ action: Action.ClearAndFocusSendMessageComposer }); + dis.dispatch({ + action: Action.ClearAndFocusSendMessageComposer, + timelineRenderingType: this.context.timelineRenderingType, + }); await sendMessage(composerContent, this.state.isRichTextEnabled, { mxClient: this.props.mxClient, roomContext: this.context, diff --git a/src/components/views/rooms/wysiwyg_composer/hooks/useWysiwygSendActionHandler.ts b/src/components/views/rooms/wysiwyg_composer/hooks/useWysiwygSendActionHandler.ts index 5cdd0b4e10..40b7e8182c 100644 --- a/src/components/views/rooms/wysiwyg_composer/hooks/useWysiwygSendActionHandler.ts +++ b/src/components/views/rooms/wysiwyg_composer/hooks/useWysiwygSendActionHandler.ts @@ -50,6 +50,9 @@ export function useWysiwygSendActionHandler( focusComposer(composerElement, context, roomContext, timeoutId); break; case Action.ClearAndFocusSendMessageComposer: + // When a thread is opened, prevent the main composer to steal the thread composer focus + if (payload.timelineRenderingType !== roomContext.timelineRenderingType) break; + composerFunctions.clear(); focusComposer(composerElement, context, roomContext, timeoutId); break; diff --git a/test/components/views/rooms/wysiwyg_composer/SendWysiwygComposer-test.tsx b/test/components/views/rooms/wysiwyg_composer/SendWysiwygComposer-test.tsx index 1a5ba88c46..7f04bf21ff 100644 --- a/test/components/views/rooms/wysiwyg_composer/SendWysiwygComposer-test.tsx +++ b/test/components/views/rooms/wysiwyg_composer/SendWysiwygComposer-test.tsx @@ -153,7 +153,7 @@ describe("SendWysiwygComposer", () => { // When we send the right action defaultDispatcher.dispatch({ action: Action.ClearAndFocusSendMessageComposer, - context: null, + timelineRenderingType: defaultRoomContext.timelineRenderingType, }); // Then the component gets the focus