Fix link-to would close & clear immediately after selecting a result

This commit is contained in:
nathan 2023-09-28 11:00:30 -06:00
parent d5f56b8bae
commit 124b6b1f96
3 changed files with 11 additions and 2 deletions

View File

@ -358,6 +358,8 @@ export class Et2LinkTo extends Et2InputWidget(ScopedElementsMixin(FormControlMix
// Clear link entry
this.select.value = {app: this.select.app, id: ""};
this.select._searchNode.clearSearch();
this.select._searchNode.select_options = [];
}
/**

View File

@ -284,7 +284,7 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
// Fixes missing empty label
this.select?.requestUpdate("value");
// Fixes incorrect opening position
this.select?.popup.handleAnchorChange();
this.select?.popup?.handleAnchorChange();
});
}
@ -581,6 +581,12 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
protected handleValueChange(e : SlChangeEvent)
{
// Only interested when selected value changes, not any nested inputs
if(e.target !== this.select)
{
return;
}
const old_value = this.__value;
this.__value = Array.isArray(this.select.value) ?
this.select.value.map(e => e.replaceAll("___", " ")) :

View File

@ -456,6 +456,7 @@ export const Et2WithSearchMixin = dedupeMixin(<T extends Constructor<LitElement>
@keydown=${this._handleSearchKeyDown}
@blur=${this._handleSearchBlur}
@sl-clear=${this._handleSearchClear}
@sl-change=${this._handleSearchChange}
></et2-textbox>
${edit}
</div>
@ -613,7 +614,7 @@ export const Et2WithSearchMixin = dedupeMixin(<T extends Constructor<LitElement>
this.remoteSearch(newValueElement, this.searchOptions).then((result : SelectOption[]) =>
{
const option = <SelectOption>result.find(o => o.value == newValueElement);
if(option)
if(option && !this._selected_remote.some(o => o.value == newValueElement))
{
this._selected_remote.push(option);
}