From 5f26b940e395dc6099b47cd2ec9b7b6b4dacad95 Mon Sep 17 00:00:00 2001 From: nathan Date: Wed, 14 Feb 2024 11:29:08 -0700 Subject: [PATCH] Et2Tree: Avoid some errors on first leaf selection --- api/js/etemplate/Et2Tree/Et2Tree.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/js/etemplate/Et2Tree/Et2Tree.ts b/api/js/etemplate/Et2Tree/Et2Tree.ts index 83a355e232..f4de3eed85 100644 --- a/api/js/etemplate/Et2Tree/Et2Tree.ts +++ b/api/js/etemplate/Et2Tree/Et2Tree.ts @@ -625,9 +625,9 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement) .selection=${this.multiple ? "multiple" : "single"} @sl-selection-change=${ (event: any) => { - this._previousOption = this._currentOption || this.getNode(this.value); + this._previousOption = this._currentOption ?? (this.value.length ? this.getNode(this.value) : null); this._currentOption = this.getNode(event.detail.selection[0].id); - event.detail.previous = this._previousOption.id; + event.detail.previous = this._previousOption?.id; this._currentSlTreeItem = event.detail.selection[0]; if(typeof this.onclick == "function") {