Skip to content

Commit 2a61db5

Browse files
disallow invalid layer drop
1 parent 8d3a8c2 commit 2a61db5

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

frontend/src/components/panels/Layers.svelte

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,16 +308,25 @@
308308
let markerHeight = 0;
309309
const layerPanel = document.querySelector("[data-layer-panel]"); // Selects the element with the data-layer-panel attribute
310310
if (layerPanel !== null && treeChildren !== undefined && treeOffset !== undefined) {
311+
const lastChild = treeChildren[treeChildren.length - 1];
312+
if (lastChild.getBoundingClientRect().bottom < clientY) {
313+
return { select, insertParentId: undefined, insertDepth: 0, insertIndex: undefined, highlightFolder: false, markerHeight: 0 };
314+
}
315+
311316
let layerPanelTop = layerPanel.getBoundingClientRect().top;
312317
Array.from(treeChildren).forEach((treeChild) => {
313-
const indexAttribute = treeChild.getAttribute("data-index");
318+
const indexAttribute = parseInt(treeChild.getAttribute("data-index") ?? "0", 10);
314319
if (!indexAttribute) return;
315-
const { folderIndex, entry: layer } = layers[parseInt(indexAttribute, 10)];
320+
const { folderIndex, entry: layer } = layers[indexAttribute];
316321
317322
const rect = treeChild.getBoundingClientRect();
318323
if (rect.top > clientY || rect.bottom < clientY) {
319324
return;
320325
}
326+
327+
const isDraggingBtnArtBoards = layers[indexAttribute]?.entry?.depth === 1 && layers[indexAttribute + 1]?.entry?.depth === 1;
328+
if (isDraggingBtnArtBoards) return;
329+
321330
const pointerPercentage = (clientY - rect.top) / rect.height;
322331
if (layer.childrenAllowed) {
323332
if (pointerPercentage < 0.25) {

0 commit comments

Comments
 (0)