From 1e277b2460f833757a7cd45e1b7d4f5c7d5008b3 Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 1 Oct 2024 14:31:05 -0600 Subject: [PATCH] Fix tree context menu on server-loaded branches --- api/js/egw_action/EgwDragDropShoelaceTree.ts | 21 ++++++++++++++++++- .../EgwPopupActionImplementation.ts | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/api/js/egw_action/EgwDragDropShoelaceTree.ts b/api/js/egw_action/EgwDragDropShoelaceTree.ts index 41681a3d61..f963783ec1 100644 --- a/api/js/egw_action/EgwDragDropShoelaceTree.ts +++ b/api/js/egw_action/EgwDragDropShoelaceTree.ts @@ -67,11 +67,30 @@ export class EgwDragDropShoelaceTree extends egwActionObjectInterface{ { return; } + if(this.stateChangeContext) + { + const target = this.tree.shadowRoot.querySelector("[id='" + this.stateChangeContext.id + "']"); + + // Just set the attribute, we're not changing the tree value + // The selected attribute will be reset by the tree next render() + if(target && egwBitIsSet(_state, EGW_AO_STATE_SELECTED)) + { + target.setAttribute("selected", ""); + } + else if(target) + { + target.removeAttribute("selected"); + } + if(target && egwBitIsSet(_state, EGW_AO_STATE_FOCUSED)) + { + target.focus(); + } + } // Update the "focused" flag if(egwBitIsSet(_state, EGW_AO_STATE_FOCUSED)) { - this.tree.focusItem(this.id); + this.tree.focus(); } if(egwBitIsSet(_state, EGW_AO_STATE_SELECTED)) { diff --git a/api/js/egw_action/EgwPopupActionImplementation.ts b/api/js/egw_action/EgwPopupActionImplementation.ts index 049d7e6e24..d536fee22d 100644 --- a/api/js/egw_action/EgwPopupActionImplementation.ts +++ b/api/js/egw_action/EgwPopupActionImplementation.ts @@ -314,7 +314,7 @@ export class EgwPopupActionImplementation implements EgwActionImplementation { event: e, posx: _xy.posx, posy: _xy.posy, innerText: nodeToUse?.title || _node.innerText,//nodeToUse only exists on widgets that define findActionTarget - target: nodeToUse?.target || _node, + target: nodeToUse || _node, }; _callback.call(contextToUse || _context, _implContext, this); }