fix: crash in category drag, closes #10932

happens when a child is dragged to root or from root to a nested level
isekai-main
Barış Soner Uşaklı 2 years ago
parent 7240e8ce57
commit 989b55d07e

@ -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;

Loading…
Cancel
Save