From c096f09b79bdf8304b7d0c7bf322ee94debd2c17 Mon Sep 17 00:00:00 2001 From: bruno Date: Mon, 13 Jul 2026 10:28:34 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20ctxMenu=20r=C3=A9activit=C3=A9=20Alpine?= =?UTF-8?q?=20=E2=80=94=20r=C3=A9assignation=20compl=C3=A8te=20au=20lieu?= =?UTF-8?q?=20de=20propri=C3=A9t=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Alpine ne détecte pas les changements sur les propriétés imbriquées d'un objet (ctxMenu.visible = true). Il faut réassigner l'objet entier: this.ctxMenu = {visible:true, x:..., y:..., node:..., tags:...} Impact: onContextMenu (show), ctxMenuOpenPage/OpenFolder/Rename/Duplicate/Delete (hide) + repositionnement dans nextTick --- app/templates/local_workspace.html | 33 ++++++++++++++++-------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/app/templates/local_workspace.html b/app/templates/local_workspace.html index 46b45bc..77a3cb8 100644 --- a/app/templates/local_workspace.html +++ b/app/templates/local_workspace.html @@ -746,16 +746,19 @@ window._wsInitData = (function() { onContextMenu(ev) { console.log('onContextMenu fired', ev.clientX, ev.clientY); var el = ev.target.closest('[data-ws-id]'); - if (!el) { this.ctxMenu.visible = false; return; } + if (!el) { this.ctxMenu = {visible:false,x:0,y:0,node:null,tags:[]}; return; } var id = parseInt(el.getAttribute('data-ws-id')); - if (!id) { this.ctxMenu.visible = false; return; } + if (!id) { this.ctxMenu = {visible:false,x:0,y:0,node:null,tags:[]}; return; } var node = this._findNodeById(this.displayTree, id); - if (!node) { this.ctxMenu.visible = false; return; } - this.ctxMenu.visible = true; - this.ctxMenu.x = ev.clientX; - this.ctxMenu.y = ev.clientY; - this.ctxMenu.node = node; - this.ctxMenu.tags = [...(node.tags||[])]; + if (!node) { this.ctxMenu = {visible:false,x:0,y:0,node:null,tags:[]}; return; } + // Reassign whole object for Alpine reactivity + this.ctxMenu = { + visible: true, + x: ev.clientX, + y: ev.clientY, + node: node, + tags: [...(node.tags||[])] + }; this.ctxTagAdding = false; this.ctxTagExistingOpen = false; this.ctxNewTagColor = '#787774'; @@ -775,8 +778,8 @@ window._wsInitData = (function() { if (y + rect.height > window.innerHeight - 4) y = window.innerHeight - rect.height - 4; if (x < 4) x = 4; if (y < 4) y = 4; - self.ctxMenu.x = x; - self.ctxMenu.y = y; + // Reassign for reactivity + self.ctxMenu = {visible:true, x:x, y:y, node:self.ctxMenu.node, tags:self.ctxMenu.tags}; }); }, @@ -826,24 +829,24 @@ window._wsInitData = (function() { ctxMenuOpenPage() { if (this.ctxMenu.node) this.openPage(this.ctxMenu.node.id); - this.ctxMenu.visible = false; + this.ctxMenu = {visible:false,x:0,y:0,node:null,tags:[]}; }, ctxMenuOpenFolder() { if (this.ctxMenu.node) this.navigateToFolder(this.ctxMenu.node.id); - this.ctxMenu.visible = false; + this.ctxMenu = {visible:false,x:0,y:0,node:null,tags:[]}; }, ctxMenuRename() { - if (this.ctxMenu.node) { this.startRename(this.ctxMenu.node); this.ctxMenu.visible = false; } + if (this.ctxMenu.node) { this.startRename(this.ctxMenu.node); this.ctxMenu = {visible:false,x:0,y:0,node:null,tags:[]}; } }, ctxMenuDuplicate() { - if (this.ctxMenu.node) { this.duplicateItem(this.ctxMenu.node); this.ctxMenu.visible = false; } + if (this.ctxMenu.node) { this.duplicateItem(this.ctxMenu.node); this.ctxMenu = {visible:false,x:0,y:0,node:null,tags:[]}; } }, ctxMenuDelete() { - if (this.ctxMenu.node) { this.deleteWithUndo(this.ctxMenu.node); this.ctxMenu.visible = false; } + if (this.ctxMenu.node) { this.deleteWithUndo(this.ctxMenu.node); this.ctxMenu = {visible:false,x:0,y:0,node:null,tags:[]}; } }, ctxRemoveTag(tagId) {