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") {