fix: toggleExpand DOM traversal robuste pour sous-dossiers renderChildren
Remplacé li.querySelector(':scope > ul.ws-tree') par une boucle sur
itemDiv.parentElement.children. Évite les problèmes de compatibilité
de :scope et trouve le <ul> frère du .ws-tree-item de manière fiable.
Chemin: btn → .ws-tree-item → parentElement (<li>) → itère children
→ premier UL.ws-tree → toggle display.
This commit is contained in:
@@ -392,14 +392,18 @@ document.addEventListener('alpine:init', function() {
|
|||||||
toggleExpand(id, btn) {
|
toggleExpand(id, btn) {
|
||||||
this.expanded[id] = !(this.expanded[id] || false);
|
this.expanded[id] = !(this.expanded[id] || false);
|
||||||
this.expanded = Object.assign({}, this.expanded);
|
this.expanded = Object.assign({}, this.expanded);
|
||||||
// For renderChildren static HTML: toggle the sibling <ul> + chevron rotation
|
// For renderChildren static HTML: toggle chevron + sibling <ul>
|
||||||
if (btn) {
|
if (btn) {
|
||||||
btn.classList.toggle('open', this.expanded[id]);
|
btn.classList.toggle('open', this.expanded[id]);
|
||||||
var li = btn.closest('li');
|
// Navigate: btn → .ws-tree-item → <li> → <ul.ws-tree>
|
||||||
if (li) {
|
var itemDiv = btn.closest('.ws-tree-item');
|
||||||
var ul = li.querySelector(':scope > ul.ws-tree');
|
if (itemDiv && itemDiv.parentElement) {
|
||||||
if (ul) {
|
var children = itemDiv.parentElement.children;
|
||||||
ul.style.display = this.expanded[id] ? '' : 'none';
|
for (var i = 0; i < children.length; i++) {
|
||||||
|
if (children[i].tagName === 'UL' && children[i].classList.contains('ws-tree')) {
|
||||||
|
children[i].style.display = this.expanded[id] ? '' : 'none';
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user