diff --git a/src/components/views/rooms/wysiwyg_composer/hooks/useInputEventProcessor.ts b/src/components/views/rooms/wysiwyg_composer/hooks/useInputEventProcessor.ts index 52d5f19e33..405539fc70 100644 --- a/src/components/views/rooms/wysiwyg_composer/hooks/useInputEventProcessor.ts +++ b/src/components/views/rooms/wysiwyg_composer/hooks/useInputEventProcessor.ts @@ -168,13 +168,15 @@ function handleInputEvent(event: InputEvent, send: Send, isCtrlEnterToSend: bool case "insertParagraph": if (!isCtrlEnterToSend) { send(); + return null; } - return null; + break; case "sendMessage": if (isCtrlEnterToSend) { send(); + return null; } - return null; + break; } return event; diff --git a/test/components/views/rooms/wysiwyg_composer/components/WysiwygComposer-test.tsx b/test/components/views/rooms/wysiwyg_composer/components/WysiwygComposer-test.tsx index 44f2a5a996..4d485b5a3f 100644 --- a/test/components/views/rooms/wysiwyg_composer/components/WysiwygComposer-test.tsx +++ b/test/components/views/rooms/wysiwyg_composer/components/WysiwygComposer-test.tsx @@ -149,8 +149,10 @@ describe("WysiwygComposer", () => { it("Should not call onSend when Enter is pressed", async () => { // When + const textbox = screen.getByRole("textbox"); + fireEvent( - screen.getByRole("textbox"), + textbox, new InputEvent("input", { inputType: "insertParagraph", }), @@ -158,6 +160,22 @@ describe("WysiwygComposer", () => { // Then it does not send a message await waitFor(() => expect(onSend).toBeCalledTimes(0)); + + fireEvent( + textbox, + new InputEvent("input", { + inputType: "insertText", + data: "other", + }), + ); + + // The focus is on the last text node + await waitFor(() => { + const selection = document.getSelection(); + if (selection) { + expect(selection.focusNode?.textContent).toEqual("other"); + } + }); }); it("Should send a message when Ctrl+Enter is pressed", async () => {