Block target picker from adding badly formatted entity (fix history crash) (#15509)

This commit is contained in:
karwosts 2023-02-20 09:14:04 -08:00 committed by GitHub
parent e21816be52
commit 05f2fb896c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,6 +18,7 @@ import { ensureArray } from "../common/array/ensure-array";
import { fireEvent } from "../common/dom/fire_event";
import { computeDomain } from "../common/entity/compute_domain";
import { computeStateName } from "../common/entity/compute_state_name";
import { isValidEntityId } from "../common/entity/valid_entity_id";
import {
computeDeviceName,
DeviceRegistryEntry,
@ -351,6 +352,11 @@ export class HaTargetPicker extends LitElement {
}
const value = ev.detail.value;
const target = ev.currentTarget;
if (target.type === "entity_id" && !isValidEntityId(value)) {
return;
}
target.value = "";
if (
this.value &&