Fix filtered out invalid values were still left in value

This commit is contained in:
nathan 2023-05-09 14:28:02 -06:00
parent d94c2f7c09
commit 2179423b03

View File

@ -448,7 +448,12 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
);
// Check for value using missing options (deleted or otherwise not allowed)
valueArray = this.filterOutMissingOptions(valueArray);
let filtered = this.filterOutMissingOptions(valueArray);
if(filtered.length != valueArray.length)
{
this.value = filtered;
return;
}
// Multiple is allowed to be empty, and if we don't have an emptyLabel nothing to do
if(this.multiple || !this.emptyLabel)
@ -713,6 +718,15 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
return tag;
}
blur()
{
if(typeof super.blur == "function")
{
super.blur();
}
this.dropdown.hide();
}
private handleTagRemove(event : CustomEvent, option)
{
event.stopPropagation();
@ -758,6 +772,15 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
}
}
private et2HandleBlur(event : Event)
{
if(typeof super.et2HandleBlur === "function")
{
super.et2HandleBlur(event);
}
this.dropdown?.hide();
}
/**
* Always close the dropdown if an option is clicked, even if multiple=true. This differs from SlSelect,
* which leaves the dropdown open for multiple=true