mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
fix: Dedupe boundElement ids when container duplicated with alt+drag (#5938)
* Dedupe boundElement ids when container duplicated with alt+drag and add spec * set to null by default
This commit is contained in:
parent
66bbfda460
commit
a86224c797
3 changed files with 41 additions and 1 deletions
|
@ -1121,5 +1121,40 @@ describe("textWysiwyg", () => {
|
|||
expect(rectangle.height).toBe(166.66666666666669);
|
||||
expect(textElement.fontSize).toBe(47.5);
|
||||
});
|
||||
|
||||
it("should bind text correctly when container duplicated with alt-drag", async () => {
|
||||
Keyboard.keyPress(KEYS.ENTER);
|
||||
|
||||
const editor = document.querySelector(
|
||||
".excalidraw-textEditorContainer > textarea",
|
||||
) as HTMLTextAreaElement;
|
||||
await new Promise((r) => setTimeout(r, 0));
|
||||
fireEvent.change(editor, { target: { value: "Hello" } });
|
||||
editor.blur();
|
||||
expect(h.elements.length).toBe(2);
|
||||
|
||||
mouse.select(rectangle);
|
||||
Keyboard.withModifierKeys({ alt: true }, () => {
|
||||
mouse.down(rectangle.x + 10, rectangle.y + 10);
|
||||
mouse.up(rectangle.x + 10, rectangle.y + 10);
|
||||
});
|
||||
expect(h.elements.length).toBe(4);
|
||||
const duplicatedRectangle = h.elements[0];
|
||||
const duplicatedText = h
|
||||
.elements[1] as ExcalidrawTextElementWithContainer;
|
||||
const originalRect = h.elements[2];
|
||||
const originalText = h.elements[3] as ExcalidrawTextElementWithContainer;
|
||||
expect(originalRect.boundElements).toStrictEqual([
|
||||
{ id: originalText.id, type: "text" },
|
||||
]);
|
||||
|
||||
expect(originalText.containerId).toBe(originalRect.id);
|
||||
|
||||
expect(duplicatedRectangle.boundElements).toStrictEqual([
|
||||
{ id: duplicatedText.id, type: "text" },
|
||||
]);
|
||||
|
||||
expect(duplicatedText.containerId).toBe(duplicatedRectangle.id);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue