From 989b55d07e6fc720e1d9792c6a192546dacc8971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sat, 1 Oct 2022 22:15:06 -0400 Subject: [PATCH] fix: crash in category drag, closes #10932 happens when a child is dragged to root or from root to a nested level --- public/src/admin/manage/categories.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/public/src/admin/manage/categories.js b/public/src/admin/manage/categories.js index cae9f782ca..d5eb350038 100644 --- a/public/src/admin/manage/categories.js +++ b/public/src/admin/manage/categories.js @@ -212,11 +212,17 @@ define('admin/manage/categories', [ const oldParentCid = parseInt(e.from.getAttribute('data-cid'), 10); const newParentCid = parseInt(e.to.getAttribute('data-cid'), 10); if (oldParentCid !== newParentCid) { - document.querySelector(`.categories li[data-cid="${newParentCid}"] .toggle`).classList.toggle('hide', false); + const toggle = document.querySelector(`.categories li[data-cid="${newParentCid}"] .toggle`); + if (toggle) { + toggle.classList.toggle('hide', false); + } const children = document.querySelectorAll(`.categories li[data-cid="${oldParentCid}"] ul[data-cid] li[data-cid]`); if (!children.length) { - document.querySelector(`.categories li[data-cid="${oldParentCid}"] .toggle`).classList.toggle('hide', true); + const toggle = document.querySelector(`.categories li[data-cid="${oldParentCid}"] .toggle`); + if (toggle) { + toggle.classList.toggle('hide', true); + } } e.item.dataset.parentCid = newParentCid;