diff --git a/src/components/ha-target-picker.ts b/src/components/ha-target-picker.ts
index 7545a19a36..b98d969d05 100644
--- a/src/components/ha-target-picker.ts
+++ b/src/components/ha-target-picker.ts
@@ -42,8 +42,8 @@ import "./entity/ha-entity-picker";
import type { HaEntityPickerEntityFilterFunc } from "./entity/ha-entity-picker";
import "./ha-area-picker";
import "./ha-icon-button";
-import "./ha-svg-icon";
import "./ha-input-helper-text";
+import "./ha-svg-icon";
@customElement("ha-target-picker")
export class HaTargetPicker extends SubscribeMixin(LitElement) {
@@ -119,55 +119,68 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
if (!this._areas || !this._devices || !this._entities) {
return html``;
}
- return html`
- ${this.horizontal ? this._renderChips() : this._renderItems()}
- ${this._renderPicker()}
- ${this.horizontal ? this._renderItems() : this._renderChips()}
-
`;
+ return html`
+ ${this.horizontal
+ ? html`
+
+ ${this._renderChips()} ${this._renderPicker()}
+
+ ${this._renderItems()}
+ `
+ : html`
+
+ ${this._renderItems()} ${this._renderPicker()}
+ ${this._renderChips()}
+
+ `}
+ `;
}
private _renderItems() {
- return html`
- ${this.value?.area_id
- ? ensureArray(this.value.area_id).map((area_id) => {
- const area = this._areas![area_id];
- return this._renderChip(
- "area_id",
- area_id,
- area?.name || area_id,
- undefined,
- mdiSofa
- );
- })
- : ""}
- ${this.value?.device_id
- ? ensureArray(this.value.device_id).map((device_id) => {
- const device = this._devices![device_id];
- return this._renderChip(
- "device_id",
- device_id,
- device ? computeDeviceName(device, this.hass) : device_id,
- undefined,
- mdiDevices
- );
- })
- : ""}
- ${this.value?.entity_id
- ? ensureArray(this.value.entity_id).map((entity_id) => {
- const entity = this.hass.states[entity_id];
- return this._renderChip(
- "entity_id",
- entity_id,
- entity ? computeStateName(entity) : entity_id,
- entity
- );
- })
- : ""}
-
`;
+ return html`
+
+ ${this.value?.area_id
+ ? ensureArray(this.value.area_id).map((area_id) => {
+ const area = this._areas![area_id];
+ return this._renderChip(
+ "area_id",
+ area_id,
+ area?.name || area_id,
+ undefined,
+ mdiSofa
+ );
+ })
+ : ""}
+ ${this.value?.device_id
+ ? ensureArray(this.value.device_id).map((device_id) => {
+ const device = this._devices![device_id];
+ return this._renderChip(
+ "device_id",
+ device_id,
+ device ? computeDeviceName(device, this.hass) : device_id,
+ undefined,
+ mdiDevices
+ );
+ })
+ : ""}
+ ${this.value?.entity_id
+ ? ensureArray(this.value.entity_id).map((entity_id) => {
+ const entity = this.hass.states[entity_id];
+ return this._renderChip(
+ "entity_id",
+ entity_id,
+ entity ? computeStateName(entity) : entity_id,
+ entity
+ );
+ })
+ : ""}
+
+ `;
}
private _renderChips() {
- return html`
+ return html`
+
${this.helper
? html`${this.helper}`
- : ""} `;
+ : ""}
+ `;
}
private async _showPicker(ev) {
@@ -320,51 +334,54 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
private _renderPicker() {
switch (this._addMode) {
case "area_id":
- return html``;
+ return html`
+
+ `;
case "device_id":
- return html``;
+ return html`
+
+ `;
case "entity_id":
- return html``;
+ return html`
+
+ `;
}
return html``;
}
@@ -553,12 +570,6 @@ export class HaTargetPicker extends SubscribeMixin(LitElement) {
static get styles(): CSSResultGroup {
return css`
${unsafeCSS(chipStyles)}
- .hidden-picker {
- height: 0px;
- display: inline-block;
- overflow: hidden;
- position: absolute;
- }
.horizontal-container {
display: flex;
flex-wrap: wrap;