Skip to content

Commit 510f06e

Browse files
disallow invalid layer drop
1 parent 2a61db5 commit 510f06e

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

frontend/src/components/panels/Layers.svelte

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,18 @@
362362
// Dragging to the empty space below all layers
363363
let lastLayer = treeChildren[treeChildren.length - 1];
364364
if (lastLayer.getBoundingClientRect().bottom < clientY) {
365-
const numberRootLayers = layers.filter((layer) => layer.entry.depth === 1).length;
366-
insertParentId = undefined;
367-
insertDepth = 0;
368-
insertIndex = numberRootLayers;
369-
markerHeight = lastLayer.getBoundingClientRect().bottom - layerPanelTop;
365+
const lastLayerIndexAttr = lastLayer.getAttribute("data-index");
366+
if (lastLayerIndexAttr) {
367+
const { folderIndex, entry: lastEntry } = layers[parseInt(lastLayerIndexAttr, 10)];
368+
369+
if (lastEntry.depth === 1) {
370+
insertParentId = undefined;
371+
} else {
372+
insertParentId = lastEntry.parentId;
373+
}
374+
insertIndex = folderIndex + 1;
375+
markerHeight = lastLayer.getBoundingClientRect().bottom - layerPanel.getBoundingClientRect().top;
376+
}
370377
}
371378
}
372379

0 commit comments

Comments
 (0)