From 1e06b9cfc5191aa47e4766549900c8cc9c68656e Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 13 Aug 2024 15:45:43 -0600 Subject: [PATCH] Et2Tabs: Better handling of child nodes --- api/js/etemplate/Layout/Et2Tabs/Et2Tabs.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/api/js/etemplate/Layout/Et2Tabs/Et2Tabs.ts b/api/js/etemplate/Layout/Et2Tabs/Et2Tabs.ts index aed38f2a9b..d82286fe6b 100644 --- a/api/js/etemplate/Layout/Et2Tabs/Et2Tabs.ts +++ b/api/js/etemplate/Layout/Et2Tabs/Et2Tabs.ts @@ -245,6 +245,22 @@ export class Et2Tabs extends Et2InputWidget(SlTabGroup) implements et2_IResizeab } }) } + + // Load any additional child nodes + for(let i = 0; i < _node.childNodes.length; i++) + { + let node = _node.childNodes[i]; + let widgetType = node.nodeName.toLowerCase(); + + // Skip text & already handled nodes + if(["#comment", "#text", "tabs", "tabpanels"].includes(widgetType)) + { + continue; + } + + // Create the new element + this.createElementFromNode(node); + } } _readTabs(tabData, tabs) @@ -308,6 +324,7 @@ export class Et2Tabs extends Et2InputWidget(SlTabGroup) implements et2_IResizeab "widget_options": widget_options, "contentDiv": null, "flagDiv": null, + "tabNode": node, "hidden": hide, "XMLNode": null, "promise": null @@ -386,6 +403,11 @@ export class Et2Tabs extends Et2InputWidget(SlTabGroup) implements et2_IResizeab // Set tab label tab.flagDiv.appendChild(document.createTextNode(tab.label)); + + if(tab.tabNode && tab.tabNode.children.length) + { + tab.flagDiv.loadFromXML(tab.tabNode); + } }); tabData.forEach((tab, index) => {