mirror of
https://github.com/element-hq/element-web
synced 2024-11-23 09:46:09 +03:00
Fix new line created when enter is pressed (#10064)
This commit is contained in:
parent
b7cd28bd29
commit
469228f45e
2 changed files with 23 additions and 3 deletions
|
@ -168,14 +168,16 @@ function handleInputEvent(event: InputEvent, send: Send, isCtrlEnterToSend: bool
|
|||
case "insertParagraph":
|
||||
if (!isCtrlEnterToSend) {
|
||||
send();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
case "sendMessage":
|
||||
if (isCtrlEnterToSend) {
|
||||
send();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
|
|
@ -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 () => {
|
||||
|
|
Loading…
Reference in a new issue