fix first category was always selected in calendar.edit as somehow select_options were set before multiple

removed the deduplicate select-first-option code now in favor of the one in firstUpdate
also automatic convert empty_label for et2-select multiple into a placeholder
This commit is contained in:
ralf 2022-06-13 14:38:26 +02:00
parent 812cdb6165
commit 980f7cb0df
2 changed files with 6 additions and 7 deletions

View File

@ -289,6 +289,12 @@ function send_template()
$attrs['multiple'] = 'true'; $attrs['multiple'] = 'true';
unset($attrs['expand_multiple_rows']); unset($attrs['expand_multiple_rows']);
} }
// automatic convert empty_label for multiple=true to a placeholder
if (!empty($attrs['empty_label']) && !empty($attrs['multiple']))
{
$attrs['placeholder'] = $attrs['empty_label'];
unset($attrs['empty_label']);
}
// type attribute need to go in widget type <select type="select-account" --> <et2-select-account // type attribute need to go in widget type <select type="select-account" --> <et2-select-account
if (empty($matches[2]) && isset($attrs['type'])) if (empty($matches[2]) && isset($attrs['type']))
{ {

View File

@ -150,13 +150,6 @@ export const Et2widgetWithSelectMixin = <T extends Constructor<LitElement>>(supe
this.__select_options = cleanSelectOptions(new_options); this.__select_options = cleanSelectOptions(new_options);
this.requestUpdate("select_options", old_options); this.requestUpdate("select_options", old_options);
// if single selection and value does not match an option, use the first option
if (!this.multiple && !this.empty_label && this.__select_options.length &&
!this.__select_options.filter(option => option.value === this.value).length)
{
this.value = this.__select_options[0].value;
}
} }
/** /**