mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 09:09:04 +01:00
Et2Select: Fix link search lost selected item, showing ?? instead
This commit is contained in:
parent
795160301b
commit
72112023e8
@ -713,6 +713,7 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
|
||||
// Tag used must match this.optionTag, but you can't use the variable directly.
|
||||
// Pass option along so SearchMixin can grab it if needed
|
||||
const value = (<string>option.value).replaceAll(" ", "___");
|
||||
const classes = option.class ? Object.fromEntries((option.class).split(" ").map(k => [k, true])) : {};
|
||||
return html`
|
||||
<sl-option
|
||||
part="option"
|
||||
@ -720,9 +721,9 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
|
||||
value="${value}"
|
||||
title="${!option.title || this.noLang ? option.title : this.egw().lang(option.title)}"
|
||||
class=${classMap({
|
||||
"match": this.searchEnabled && option.isMatch,
|
||||
"no-match": this.searchEnabled && !option.isMatch,
|
||||
...Object.fromEntries((option.class || "").split(" ").map(k => [k, true]))
|
||||
"match": this.searchEnabled && (option.isMatch || false),
|
||||
"no-match": this.searchEnabled && !(option.isMatch || false),
|
||||
...classes
|
||||
})}
|
||||
.option=${option}
|
||||
.selected=${this.getValueAsArray().some(v => v == value)}
|
||||
|
@ -804,21 +804,7 @@ export const Et2WithSearchMixin = dedupeMixin(<T extends Constructor<LitElement>
|
||||
|
||||
// Find and keep any selected remote entries
|
||||
// Doing it here catches keypress changes too
|
||||
this.select.querySelectorAll("[aria-selected=true].remote").forEach((node) =>
|
||||
{
|
||||
const value = node.value.replaceAll("___", " ");
|
||||
if(!node.selected || this._selected_remote.some(o => o.value == value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
const remote_option_index = this._remote_options.findIndex(o => o.value == value);
|
||||
if(remote_option_index >= 0)
|
||||
{
|
||||
console.log("Keeping " + value, this._remote_options[remote_option_index]);
|
||||
this._selected_remote.push(node.option);
|
||||
this._remote_options.splice(remote_option_index, 1);
|
||||
}
|
||||
});
|
||||
this._keepSelectedRemote();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -845,13 +831,31 @@ export const Et2WithSearchMixin = dedupeMixin(<T extends Constructor<LitElement>
|
||||
// Find the tag
|
||||
const path = event.composedPath();
|
||||
const tag = <Et2Tag>path.find((el) => el instanceof Et2Tag);
|
||||
this.dropdown.hide();
|
||||
this.hide();
|
||||
this.updateComplete.then(() =>
|
||||
{
|
||||
tag.startEdit(event);
|
||||
});
|
||||
}
|
||||
|
||||
_keepSelectedRemote()
|
||||
{
|
||||
this.select.querySelectorAll("[aria-selected=true].remote").forEach((node) =>
|
||||
{
|
||||
const value = node.value.replaceAll("___", " ");
|
||||
if(!node.selected || this._selected_remote.some(o => o.value == value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
const remote_option_index = this._remote_options.findIndex(o => o.value == value);
|
||||
if(remote_option_index >= 0)
|
||||
{
|
||||
console.log("Keeping " + value, this._remote_options[remote_option_index]);
|
||||
this._selected_remote.push(node.option);
|
||||
this._remote_options.splice(remote_option_index, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* An option was selected
|
||||
*/
|
||||
@ -1097,12 +1101,8 @@ export const Et2WithSearchMixin = dedupeMixin(<T extends Constructor<LitElement>
|
||||
{
|
||||
let target = this._optionTargetNode || this;
|
||||
|
||||
// Remove any previously selected remote options that aren't used anymore
|
||||
this._selected_remote = this._selected_remote.filter((option) =>
|
||||
{
|
||||
return this.multiple ? this.value.indexOf(<string>option.value) != -1 : this.value == option.value;
|
||||
});
|
||||
|
||||
this._keepSelectedRemote();
|
||||
|
||||
this._remote_options = [];
|
||||
|
||||
// Not searching anymore, clear flag
|
||||
|
Loading…
Reference in New Issue
Block a user