harden relocate.js: observe stable parent so items re-relocate after #board-container rebuild; v1.1

This commit is contained in:
2026-07-06 21:19:06 -03:00
parent 9c27b51eed
commit a5721890a6
3 changed files with 11 additions and 6 deletions

View File

@@ -77,16 +77,21 @@
}
function init() {
if (!document.getElementById("board")) {
var container = document.getElementById("board-container");
if (!container) {
return;
}
apply();
var container = document.getElementById("board-container");
// Observe the STABLE parent, not #board-container: Kanboard replaces the container
// on every card drop / AJAX poll (BoardDragAndDrop.refresh), which would kill an
// observer bound to the container itself and leave the items un-relocated after a
// move. The parent survives, so apply() keeps running on every rebuild.
var parent = container.parentNode;
if (container && window.MutationObserver) {
new MutationObserver(apply).observe(container, { childList: true, subtree: true });
if (parent && window.MutationObserver) {
new MutationObserver(apply).observe(parent, { childList: true, subtree: true });
}
}