mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-15 20:54:59 +08:00
Fix new line created when enter is pressed (#10064)
This commit is contained in:
parent
b7cd28bd29
commit
469228f45e
@ -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;
|
||||
|
@ -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 New Issue
Block a user