Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Fix cursor position when new line is created by pressing enter (RTE) #10064

Merged
merged 2 commits into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,33 @@ 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",
}),
);

// 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 () => {
Expand Down