Fix keyboard in automation-picker menus (#23867)

This commit is contained in:
karwosts 2025-01-27 23:39:03 -08:00 committed by GitHub
parent 5204a565cf
commit c1c6d71ccf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -403,7 +403,7 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
(category) => (category) =>
html`<ha-md-menu-item html`<ha-md-menu-item
.value=${category.category_id} .value=${category.category_id}
@click=${this._handleBulkCategory} .clickAction=${this._handleBulkCategory}
> >
${category.icon ${category.icon
? html`<ha-icon slot="start" .icon=${category.icon}></ha-icon>` ? html`<ha-icon slot="start" .icon=${category.icon}></ha-icon>`
@ -411,7 +411,7 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
<div slot="headline">${category.name}</div> <div slot="headline">${category.name}</div>
</ha-md-menu-item>` </ha-md-menu-item>`
)} )}
<ha-md-menu-item .value=${null} @click=${this._handleBulkCategory}> <ha-md-menu-item .value=${null} .clickAction=${this._handleBulkCategory}>
<div slot="headline"> <div slot="headline">
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.automation.picker.bulk_actions.no_category" "ui.panel.config.automation.picker.bulk_actions.no_category"
@ -419,7 +419,7 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
</div> </div>
</ha-md-menu-item> </ha-md-menu-item>
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider> <ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
<ha-md-menu-item @click=${this._bulkCreateCategory}> <ha-md-menu-item .clickAction=${this._bulkCreateCategory}>
<div slot="headline"> <div slot="headline">
${this.hass.localize("ui.panel.config.category.editor.add")} ${this.hass.localize("ui.panel.config.category.editor.add")}
</div> </div>
@ -456,7 +456,7 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
</ha-md-menu-item>`; </ha-md-menu-item>`;
})} })}
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider> <ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
<ha-md-menu-item @click=${this._bulkCreateLabel}> <ha-md-menu-item .clickAction=${this._bulkCreateLabel}>
<div slot="headline"> <div slot="headline">
${this.hass.localize("ui.panel.config.labels.add_label")} ${this.hass.localize("ui.panel.config.labels.add_label")}
</div></ha-md-menu-item </div></ha-md-menu-item
@ -466,7 +466,7 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
(area) => (area) =>
html`<ha-md-menu-item html`<ha-md-menu-item
.value=${area.area_id} .value=${area.area_id}
@click=${this._handleBulkArea} .clickAction=${this._handleBulkArea}
> >
${area.icon ${area.icon
? html`<ha-icon slot="start" .icon=${area.icon}></ha-icon>` ? html`<ha-icon slot="start" .icon=${area.icon}></ha-icon>`
@ -477,7 +477,7 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
<div slot="headline">${area.name}</div> <div slot="headline">${area.name}</div>
</ha-md-menu-item>` </ha-md-menu-item>`
)} )}
<ha-md-menu-item .value=${null} @click=${this._handleBulkArea}> <ha-md-menu-item .value=${null} .clickAction=${this._handleBulkArea}>
<div slot="headline"> <div slot="headline">
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.devices.picker.bulk_actions.no_area" "ui.panel.config.devices.picker.bulk_actions.no_area"
@ -485,7 +485,7 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
</div> </div>
</ha-md-menu-item> </ha-md-menu-item>
<ha-md-divider role="separator" tabindex="-1"></ha-md-divider> <ha-md-divider role="separator" tabindex="-1"></ha-md-divider>
<ha-md-menu-item @click=${this._bulkCreateArea}> <ha-md-menu-item .clickAction=${this._bulkCreateArea}>
<div slot="headline"> <div slot="headline">
${this.hass.localize( ${this.hass.localize(
"ui.panel.config.devices.picker.bulk_actions.add_area" "ui.panel.config.devices.picker.bulk_actions.add_area"
@ -760,7 +760,7 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
</ha-sub-menu>` </ha-sub-menu>`
: nothing : nothing
} }
<ha-md-menu-item @click=${this._handleBulkEnable}> <ha-md-menu-item .clickAction=${this._handleBulkEnable}>
<ha-svg-icon slot="start" .path=${mdiToggleSwitch}></ha-svg-icon> <ha-svg-icon slot="start" .path=${mdiToggleSwitch}></ha-svg-icon>
<div slot="headline"> <div slot="headline">
${this.hass.localize( ${this.hass.localize(
@ -768,7 +768,7 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
)} )}
</div> </div>
</ha-md-menu-item> </ha-md-menu-item>
<ha-md-menu-item @click=${this._handleBulkDisable}> <ha-md-menu-item .clickAction=${this._handleBulkDisable}>
<ha-svg-icon <ha-svg-icon
slot="start" slot="start"
.path=${mdiToggleSwitchOffOutline} .path=${mdiToggleSwitchOffOutline}
@ -1243,10 +1243,10 @@ class HaAutomationPicker extends SubscribeMixin(LitElement) {
} }
} }
private async _handleBulkCategory(ev) { private _handleBulkCategory = async (item) => {
const category = ev.currentTarget.value; const category = item.value;
this._bulkAddCategory(category); this._bulkAddCategory(category);
} };
private async _bulkAddCategory(category: string) { private async _bulkAddCategory(category: string) {
const promises: Promise<UpdateEntityRegistryEntryResult>[] = []; const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
@ -1309,10 +1309,10 @@ ${rejected
} }
} }
private async _handleBulkArea(ev) { private _handleBulkArea = (item) => {
const area = ev.currentTarget.value; const area = item.value;
this._bulkAddArea(area); this._bulkAddArea(area);
} };
private async _bulkAddArea(area: string) { private async _bulkAddArea(area: string) {
const promises: Promise<UpdateEntityRegistryEntryResult>[] = []; const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
@ -1339,7 +1339,7 @@ ${rejected
} }
} }
private async _bulkCreateArea() { private _bulkCreateArea = async () => {
showAreaRegistryDetailDialog(this, { showAreaRegistryDetailDialog(this, {
createEntry: async (values) => { createEntry: async (values) => {
const area = await createAreaRegistryEntry(this.hass, values); const area = await createAreaRegistryEntry(this.hass, values);
@ -1347,9 +1347,9 @@ ${rejected
return area; return area;
}, },
}); });
} };
private async _handleBulkEnable() { private _handleBulkEnable = async () => {
const promises: Promise<ServiceCallResponse>[] = []; const promises: Promise<ServiceCallResponse>[] = [];
this._selected.forEach((entityId) => { this._selected.forEach((entityId) => {
promises.push(turnOnOffEntity(this.hass, entityId, true)); promises.push(turnOnOffEntity(this.hass, entityId, true));
@ -1368,9 +1368,9 @@ ${rejected
>`, >`,
}); });
} }
} };
private async _handleBulkDisable() { private _handleBulkDisable = async () => {
const promises: Promise<ServiceCallResponse>[] = []; const promises: Promise<ServiceCallResponse>[] = [];
this._selected.forEach((entityId) => { this._selected.forEach((entityId) => {
promises.push(turnOnOffEntity(this.hass, entityId, false)); promises.push(turnOnOffEntity(this.hass, entityId, false));
@ -1389,9 +1389,9 @@ ${rejected
>`, >`,
}); });
} }
} };
private async _bulkCreateCategory() { private _bulkCreateCategory = async () => {
showCategoryRegistryDetailDialog(this, { showCategoryRegistryDetailDialog(this, {
scope: "automation", scope: "automation",
createEntry: async (values) => { createEntry: async (values) => {
@ -1404,9 +1404,9 @@ ${rejected
return category; return category;
}, },
}); });
} };
private _bulkCreateLabel() { private _bulkCreateLabel = () => {
showLabelDetailDialog(this, { showLabelDetailDialog(this, {
createEntry: async (values) => { createEntry: async (values) => {
const label = await createLabelRegistryEntry(this.hass, values); const label = await createLabelRegistryEntry(this.hass, values);
@ -1414,7 +1414,7 @@ ${rejected
return label; return label;
}, },
}); });
} };
private _handleSortingChanged(ev: CustomEvent) { private _handleSortingChanged(ev: CustomEvent) {
this._activeSorting = ev.detail; this._activeSorting = ev.detail;