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) {
|
||||
this.expanded[id] = !(this.expanded[id] || false);
|
||||
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) {
|
||||
btn.classList.toggle('open', this.expanded[id]);
|
||||
var li = btn.closest('li');
|
||||
if (li) {
|
||||
var ul = li.querySelector(':scope > ul.ws-tree');
|
||||
if (ul) {
|
||||
ul.style.display = this.expanded[id] ? '' : 'none';
|
||||
// Navigate: btn → .ws-tree-item → <li> → <ul.ws-tree>
|
||||
var itemDiv = btn.closest('.ws-tree-item');
|
||||
if (itemDiv && itemDiv.parentElement) {
|
||||
var children = itemDiv.parentElement.children;
|
||||
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