fix(library): splice au lieu d'assignation pour Alpine 3.14.9 x-for
Alpine 3.14.9 ne détecte pas le changement de référence d'array (this.flatItems = result). Utilisation de splice() pour muter l'array en place. Ajout de $nextTick pour forcer le re-render.
This commit is contained in:
@@ -379,7 +379,8 @@ function libraryPage() {
|
||||
return (r.title || '').toLowerCase().indexOf(q) !== -1;
|
||||
});
|
||||
}
|
||||
this.flatItems = result;
|
||||
// Use splice for Alpine 3.14.9 reactivity (array reference reassign fails)
|
||||
this.flatItems.splice(0, this.flatItems.length, ...result);
|
||||
this.selectedCount = Object.keys(this.selected).length;
|
||||
this.allSelected = this.flatItems.length > 0 && this.selectedCount === this.flatItems.length;
|
||||
},
|
||||
@@ -483,11 +484,14 @@ function libraryPage() {
|
||||
this._markTree(this.items, 0);
|
||||
this._recomputeFlatItems();
|
||||
console.log('[Library] flatItems after recompute: ' + this.flatItems.length);
|
||||
// Force Alpine to re-render (known issue with x-for in 3.14.9)
|
||||
var self = this;
|
||||
this.$nextTick(function() { self.loading = false; });
|
||||
} catch(e) {
|
||||
console.error('[Library] load error:', e);
|
||||
this.items = [];
|
||||
this.loading = false;
|
||||
}
|
||||
this.loading = false;
|
||||
},
|
||||
|
||||
_markTree(nodes, depth) {
|
||||
|
||||
Reference in New Issue
Block a user