From 7f31acf7642cc316569f9283b34d5d9304cbc50a Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Fri, 6 Dec 2024 16:14:30 +0100 Subject: [PATCH] Fix label selector when required (#23186) --- src/components/ha-form/compute-initial-ha-form-data.ts | 2 ++ src/components/ha-selector/ha-selector-label.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/components/ha-form/compute-initial-ha-form-data.ts b/src/components/ha-form/compute-initial-ha-form-data.ts index b74ad95fe906..53e348832875 100644 --- a/src/components/ha-form/compute-initial-ha-form-data.ts +++ b/src/components/ha-form/compute-initial-ha-form-data.ts @@ -47,6 +47,8 @@ export const computeInitialHaFormData = ( data[field.name] = selector.entity?.multiple ? [] : ""; } else if ("area" in selector) { data[field.name] = selector.area?.multiple ? [] : ""; + } else if ("label" in selector) { + data[field.name] = selector.label?.multiple ? [] : ""; } else if ("boolean" in selector) { data[field.name] = false; } else if ( diff --git a/src/components/ha-selector/ha-selector-label.ts b/src/components/ha-selector/ha-selector-label.ts index 72a5d8ee57b0..d2b40986833e 100644 --- a/src/components/ha-selector/ha-selector-label.ts +++ b/src/components/ha-selector/ha-selector-label.ts @@ -34,6 +34,7 @@ export class HaLabelSelector extends LitElement { no-add .hass=${this.hass} .value=${ensureArray(this.value ?? [])} + .required=${this.required} .disabled=${this.disabled} .label=${this.label} @value-changed=${this._handleChange} @@ -46,6 +47,7 @@ export class HaLabelSelector extends LitElement { no-add .hass=${this.hass} .value=${this.value} + .required=${this.required} .disabled=${this.disabled} .label=${this.label} @value-changed=${this._handleChange}