mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 11:46:42 +00:00
Fix multiselect without data (#4906)
This commit is contained in:
parent
4675579f79
commit
e265d9581c
@ -41,6 +41,7 @@ export class HaFormMultiSelect extends LitElement implements HaFormElement {
|
|||||||
? this.schema.options
|
? this.schema.options
|
||||||
: Object.entries(this.schema.options!);
|
: Object.entries(this.schema.options!);
|
||||||
|
|
||||||
|
const data = this.data || [];
|
||||||
return html`
|
return html`
|
||||||
<paper-menu-button horizontal-align="right" vertical-offset="8">
|
<paper-menu-button horizontal-align="right" vertical-offset="8">
|
||||||
<div class="dropdown-trigger" slot="dropdown-trigger">
|
<div class="dropdown-trigger" slot="dropdown-trigger">
|
||||||
@ -49,7 +50,7 @@ export class HaFormMultiSelect extends LitElement implements HaFormElement {
|
|||||||
id="input"
|
id="input"
|
||||||
type="text"
|
type="text"
|
||||||
readonly
|
readonly
|
||||||
value=${this.data
|
value=${data
|
||||||
.map((value) => this.schema.options![value] || value)
|
.map((value) => this.schema.options![value] || value)
|
||||||
.join(", ")}
|
.join(", ")}
|
||||||
label=${this.label}
|
label=${this.label}
|
||||||
@ -68,7 +69,7 @@ export class HaFormMultiSelect extends LitElement implements HaFormElement {
|
|||||||
multi
|
multi
|
||||||
slot="dropdown-content"
|
slot="dropdown-content"
|
||||||
attr-for-selected="item-value"
|
attr-for-selected="item-value"
|
||||||
.selectedValues=${this.data}
|
.selectedValues=${data}
|
||||||
@selected-items-changed=${this._valueChanged}
|
@selected-items-changed=${this._valueChanged}
|
||||||
@iron-select=${this._onSelect}
|
@iron-select=${this._onSelect}
|
||||||
>
|
>
|
||||||
@ -79,7 +80,7 @@ export class HaFormMultiSelect extends LitElement implements HaFormElement {
|
|||||||
return html`
|
return html`
|
||||||
<paper-icon-item .itemValue=${value}>
|
<paper-icon-item .itemValue=${value}>
|
||||||
<paper-checkbox
|
<paper-checkbox
|
||||||
.checked=${this.data.includes(value)}
|
.checked=${data.includes(value)}
|
||||||
slot="item-icon"
|
slot="item-icon"
|
||||||
></paper-checkbox>
|
></paper-checkbox>
|
||||||
${this._optionLabel(item)}
|
${this._optionLabel(item)}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user