Fix alt+drag z order and restore tests

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
Mark Tolmacs 2025-03-19 15:15:59 +01:00
parent 0e92b1206f
commit 00fe0c4ab0
No known key found for this signature in database
4 changed files with 41 additions and 41 deletions

View file

@ -194,7 +194,7 @@ export const duplicateElements = (
}
elementsWithClones.splice(
index + (opts?.reverseOrder ? 0 : +1),
index + (opts?.reverseOrder ? -1 : +1),
0,
...castArray(elements),
);

View file

@ -1,6 +1,40 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`duplicate element on move when ALT is clicked > rectangle 5`] = `
{
"angle": 0,
"backgroundColor": "transparent",
"boundElements": null,
"customData": undefined,
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 50,
"id": "id2",
"index": "Zz",
"isDeleted": false,
"link": null,
"locked": false,
"opacity": 100,
"roughness": 1,
"roundness": {
"type": 3,
},
"seed": 238820263,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 6,
"versionNonce": 1604849351,
"width": 30,
"x": 30,
"y": 20,
}
`;
exports[`duplicate element on move when ALT is clicked > rectangle 6`] = `
{
"angle": 0,
"backgroundColor": "transparent",
@ -34,40 +68,6 @@ exports[`duplicate element on move when ALT is clicked > rectangle 5`] = `
}
`;
exports[`duplicate element on move when ALT is clicked > rectangle 6`] = `
{
"angle": 0,
"backgroundColor": "transparent",
"boundElements": null,
"customData": undefined,
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 50,
"id": "id2",
"index": "a1",
"isDeleted": false,
"link": null,
"locked": false,
"opacity": 100,
"roughness": 1,
"roundness": {
"type": 3,
},
"seed": 238820263,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 6,
"versionNonce": 1604849351,
"width": 30,
"x": 30,
"y": 20,
}
`;
exports[`move element > rectangle 5`] = `
{
"angle": 0,

View file

@ -2139,7 +2139,7 @@ History {
"frameId": null,
"groupIds": [],
"height": 10,
"index": "a1",
"index": "Zz",
"isDeleted": false,
"link": null,
"locked": false,
@ -10629,7 +10629,7 @@ History {
"id7",
],
"height": 10,
"index": "a3",
"index": "a0G",
"isDeleted": false,
"link": null,
"locked": false,
@ -10662,7 +10662,7 @@ History {
"id7",
],
"height": 10,
"index": "a4",
"index": "a0V",
"isDeleted": false,
"link": null,
"locked": false,
@ -10695,7 +10695,7 @@ History {
"id7",
],
"height": 10,
"index": "a5",
"index": "a0l",
"isDeleted": false,
"link": null,
"locked": false,

View file

@ -175,8 +175,8 @@ describe("duplicate element on move when ALT is clicked", () => {
expect(h.elements.length).toEqual(2);
// behavior should be the same as Ctrl+D
expect([h.elements[0].x, h.elements[0].y]).toEqual([-10, 60]);
expect([h.elements[1].x, h.elements[1].y]).toEqual([30, 20]);
expect([h.elements[0].x, h.elements[0].y]).toEqual([30, 20]);
expect([h.elements[1].x, h.elements[1].y]).toEqual([-10, 60]);
h.elements.forEach((element) => expect(element).toMatchSnapshot());
});