Fix more info remote (#19575)

This commit is contained in:
Bram Kragten 2024-01-30 13:51:12 +01:00 committed by GitHub
parent 767b2b6b9c
commit 73460c7d8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,6 @@
import "@material/mwc-list/mwc-list"; import "@material/mwc-select/mwc-select";
import "@material/mwc-list/mwc-list-item"; import "@material/mwc-list/mwc-list-item";
import { html, LitElement, nothing } from "lit"; import { css, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators"; import { customElement, property } from "lit/decorators";
import { stopPropagation } from "../../../common/dom/stop_propagation"; import { stopPropagation } from "../../../common/dom/stop_propagation";
import { supportsFeature } from "../../../common/entity/supports-feature"; import { supportsFeature } from "../../../common/entity/supports-feature";
@ -26,17 +26,17 @@ class MoreInfoRemote extends LitElement {
return html` return html`
${supportsFeature(stateObj, REMOTE_SUPPORT_ACTIVITY) ${supportsFeature(stateObj, REMOTE_SUPPORT_ACTIVITY)
? html` ? html`
<mwc-list <mwc-select
.label=${this.hass!.localize( .label=${this.hass!.localize(
"ui.dialogs.more_info_control.remote.activity" "ui.dialogs.more_info_control.remote.activity"
)} )}
.value=${stateObj.attributes.current_activity} .value=${stateObj.attributes.current_activity || ""}
@selected=${this.handleActivityChanged} @selected=${this._handleActivityChanged}
fixedMenuPosition fixedMenuPosition
naturalMenuWidth naturalMenuWidth
@closed=${stopPropagation} @closed=${stopPropagation}
> >
${stateObj.attributes.activity_list!.map( ${stateObj.attributes.activity_list?.map(
(activity) => html` (activity) => html`
<mwc-list-item .value=${activity}> <mwc-list-item .value=${activity}>
${this.hass.formatEntityAttributeValue( ${this.hass.formatEntityAttributeValue(
@ -47,7 +47,7 @@ class MoreInfoRemote extends LitElement {
</mwc-list-item> </mwc-list-item>
` `
)} )}
</mwc-list> </mwc-select>
` `
: nothing} : nothing}
@ -59,7 +59,7 @@ class MoreInfoRemote extends LitElement {
`; `;
} }
private handleActivityChanged(ev) { private _handleActivityChanged(ev) {
const oldVal = this.stateObj!.attributes.current_activity; const oldVal = this.stateObj!.attributes.current_activity;
const newVal = ev.target.value; const newVal = ev.target.value;
@ -72,6 +72,12 @@ class MoreInfoRemote extends LitElement {
activity: newVal, activity: newVal,
}); });
} }
static styles = css`
mwc-select {
width: 100%;
}
`;
} }
declare global { declare global {