Merge pull request #9969 from matrix-org/florianduros/fix/thread-rte-focus

Fix RTE focus behaviour in threads
t3chguy/dedup-icons-17oct
Florian Duros 2023-01-24 09:51:31 +01:00 committed by GitHub
commit 60edb85a1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View File

@ -336,7 +336,10 @@ export class MessageComposer extends React.Component<IProps, IState> {
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,

View File

@ -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;

View File

@ -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