1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-04-17 23:54:28 +01:00

Hide behavior selector if no targets are populated (#30219)

This commit is contained in:
Aidan Timson
2026-03-19 10:48:18 +00:00
committed by GitHub
parent e278e33375
commit e819c30151
2 changed files with 34 additions and 7 deletions

View File

@@ -95,7 +95,12 @@ export class HaPlatformCondition extends LitElement {
loadDefaults &&
field.selector &&
field.default !== undefined &&
updatedOptions[key] === undefined
updatedOptions[key] === undefined &&
!(
key === "behavior" &&
this.description?.target &&
!this.condition?.target
)
) {
updatedDefaultValue = true;
updatedOptions[key] = field.default;
@@ -225,7 +230,13 @@ export class HaPlatformCondition extends LitElement {
return nothing;
}
if (fieldName === "behavior" && this._resolvedTargetEntityCount === 1) {
if (
fieldName === "behavior" &&
this.description?.target &&
(!this.condition?.target ||
(this._resolvedTargetEntityCount !== undefined &&
this._resolvedTargetEntityCount <= 1))
) {
return nothing;
}
@@ -420,7 +431,9 @@ export class HaPlatformCondition extends LitElement {
await this._resolveTargetEntityCount(target);
if (
this._resolvedTargetEntityCount === 1 &&
(!target ||
(this._resolvedTargetEntityCount !== undefined &&
this._resolvedTargetEntityCount <= 1)) &&
this.condition.options?.behavior !== undefined
) {
const options = { ...this.condition.options };
@@ -433,6 +446,7 @@ export class HaPlatformCondition extends LitElement {
},
});
} else if (
target &&
this._resolvedTargetEntityCount !== undefined &&
this._resolvedTargetEntityCount > 1 &&
this.condition.options?.behavior === undefined

View File

@@ -130,7 +130,12 @@ export class HaPlatformTrigger extends LitElement {
loadDefaults &&
field.selector &&
field.default !== undefined &&
updatedOptions[key] === undefined
updatedOptions[key] === undefined &&
!(
key === "behavior" &&
this.description?.target &&
!this.trigger?.target
)
) {
updatedDefaultValue = true;
updatedOptions[key] = field.default;
@@ -261,8 +266,13 @@ export class HaPlatformTrigger extends LitElement {
return nothing;
}
// Hide behavior when the target is a single direct entity.
if (fieldName === "behavior" && this._resolvedTargetEntityCount === 1) {
if (
fieldName === "behavior" &&
this.description?.target &&
(!this.trigger?.target ||
(this._resolvedTargetEntityCount !== undefined &&
this._resolvedTargetEntityCount <= 1))
) {
return nothing;
}
@@ -457,7 +467,9 @@ export class HaPlatformTrigger extends LitElement {
await this._resolveTargetEntityCount(target);
if (
this._resolvedTargetEntityCount === 1 &&
(!target ||
(this._resolvedTargetEntityCount !== undefined &&
this._resolvedTargetEntityCount <= 1)) &&
this.trigger.options?.behavior !== undefined
) {
const options = { ...this.trigger.options };
@@ -470,6 +482,7 @@ export class HaPlatformTrigger extends LitElement {
},
});
} else if (
target &&
this._resolvedTargetEntityCount !== undefined &&
this._resolvedTargetEntityCount > 1 &&
this.trigger.options?.behavior === undefined