You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-08-07 21:23:00 +03:00
Fix link creation with backward selection (#9986)
Fix link creation with backward selection
This commit is contained in:
@@ -299,6 +299,7 @@ describe("SendWysiwygComposer", () => {
|
||||
anchorOffset: 2,
|
||||
focusNode: textNode,
|
||||
focusOffset: 2,
|
||||
isForward: true,
|
||||
});
|
||||
// the event is not automatically fired by jest
|
||||
document.dispatchEvent(new CustomEvent("selectionchange"));
|
||||
@@ -308,6 +309,32 @@ describe("SendWysiwygComposer", () => {
|
||||
// Then
|
||||
await waitFor(() => expect(screen.getByRole("textbox")).toHaveTextContent(/wo🦫rd/));
|
||||
});
|
||||
|
||||
it("Should add an emoji when a word is selected", async () => {
|
||||
// When
|
||||
screen.getByRole("textbox").focus();
|
||||
screen.getByRole("textbox").innerHTML = "word";
|
||||
fireEvent.input(screen.getByRole("textbox"), {
|
||||
data: "word",
|
||||
inputType: "insertText",
|
||||
});
|
||||
|
||||
const textNode = screen.getByRole("textbox").firstChild;
|
||||
await setSelection({
|
||||
anchorNode: textNode,
|
||||
anchorOffset: 3,
|
||||
focusNode: textNode,
|
||||
focusOffset: 2,
|
||||
isForward: false,
|
||||
});
|
||||
// the event is not automatically fired by jest
|
||||
document.dispatchEvent(new CustomEvent("selectionchange"));
|
||||
|
||||
emojiButton.click();
|
||||
|
||||
// Then
|
||||
await waitFor(() => expect(screen.getByRole("textbox")).toHaveTextContent(/wo🦫d/));
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
|
@@ -35,6 +35,7 @@ describe("LinkModal", () => {
|
||||
anchorNode: null,
|
||||
focusOffset: 3,
|
||||
anchorOffset: 4,
|
||||
isForward: true,
|
||||
};
|
||||
|
||||
const customRender = (isTextEnabled: boolean, onClose: () => void, isEditing = false) => {
|
||||
|
Reference in New Issue
Block a user