From 0287ce0e0dfc8e4da42b43680043b61c8002d814 Mon Sep 17 00:00:00 2001 From: ralf Date: Wed, 6 Mar 2024 18:20:07 +0200 Subject: [PATCH] fix getValue() --- api/js/etemplate/Et2Tree/Et2Tree.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/api/js/etemplate/Et2Tree/Et2Tree.ts b/api/js/etemplate/Et2Tree/Et2Tree.ts index a297dbeed2..1a3e975944 100644 --- a/api/js/etemplate/Et2Tree/Et2Tree.ts +++ b/api/js/etemplate/Et2Tree/Et2Tree.ts @@ -347,7 +347,7 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement) */ public getSelectedItem(): TreeItemData { - return this._currentOption || this._selectOptions[0] + return this._currentOption || (this._selectOptions ? this._selectOptions[0] : null); } /** @@ -356,17 +356,19 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement) */ getValue() { - if(this.multiple){ - let res:string[] = [] - if(this.selectedNodes?.length) - for (const selectedNode of this.selectedNodes) + if(this.multiple) + { + let res:string[] = []; + if(this.selectedNodes?.length) { - res.push(selectedNode.id) + for (const selectedNode of this.selectedNodes) + { + res.push(selectedNode.id); + } } - return res} - else { - this.getSelectedItem().id + return res; } + return this.getSelectedItem()?.id; } /**