1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-04-19 16:31:31 +01:00

Fix more keyboard menus (devices/helpers/scenes/scripts) (#24037)

* Fix more keyboard menus (devices/helpers/scenes/scripts)

* Apply suggestions from code review

Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com>

* less async

---------

Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com>
This commit is contained in:
karwosts
2025-02-03 06:13:20 -08:00
committed by GitHub
parent 67b970fcaa
commit 7d1f8d618a
4 changed files with 60 additions and 60 deletions

View File

@@ -410,7 +410,7 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
(category) =>
html`<ha-md-menu-item
.value=${category.category_id}
@click=${this._handleBulkCategory}
.clickAction=${this._handleBulkCategory}
>
${category.icon
? html`<ha-icon slot="start" .icon=${category.icon}></ha-icon>`
@@ -418,14 +418,14 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
<div slot="headline">${category.name}</div>
</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">
${this.hass.localize(
"ui.panel.config.automation.picker.bulk_actions.no_category"
)}
</div> </ha-md-menu-item
><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">
${this.hass.localize("ui.panel.config.category.editor.add")}
</div>
@@ -462,7 +462,7 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
</ha-md-menu-item>`;
})}
<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">
${this.hass.localize("ui.panel.config.labels.add_label")}
</div></ha-md-menu-item
@@ -472,7 +472,7 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
(area) =>
html`<ha-md-menu-item
.value=${area.area_id}
@click=${this._handleBulkArea}
.clickAction=${this._handleBulkArea}
>
${area.icon
? html`<ha-icon slot="start" .icon=${area.icon}></ha-icon>`
@@ -483,7 +483,7 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
<div slot="headline">${area.name}</div>
</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">
${this.hass.localize(
"ui.panel.config.devices.picker.bulk_actions.no_area"
@@ -491,7 +491,7 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
</div>
</ha-md-menu-item>
<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">
${this.hass.localize(
"ui.panel.config.devices.picker.bulk_actions.add_area"
@@ -977,10 +977,10 @@ class HaScriptPicker extends SubscribeMixin(LitElement) {
this._selected = ev.detail.value;
}
private async _handleBulkCategory(ev) {
const category = ev.currentTarget.value;
private _handleBulkCategory = (item) => {
const category = item.value;
this._bulkAddCategory(category);
}
};
private async _bulkAddCategory(category: string) {
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
@@ -1185,7 +1185,7 @@ ${rejected
}
}
private async _bulkCreateCategory() {
private _bulkCreateCategory = () => {
showCategoryRegistryDetailDialog(this, {
scope: "script",
createEntry: async (values) => {
@@ -1198,9 +1198,9 @@ ${rejected
return category;
},
});
}
};
private _bulkCreateLabel() {
private _bulkCreateLabel = () => {
showLabelDetailDialog(this, {
createEntry: async (values) => {
const label = await createLabelRegistryEntry(this.hass, values);
@@ -1208,12 +1208,12 @@ ${rejected
return label;
},
});
}
};
private async _handleBulkArea(ev) {
const area = ev.currentTarget.value;
private _handleBulkArea = (item) => {
const area = item.value;
this._bulkAddArea(area);
}
};
private async _bulkAddArea(area: string) {
const promises: Promise<UpdateEntityRegistryEntryResult>[] = [];
@@ -1240,7 +1240,7 @@ ${rejected
}
}
private async _bulkCreateArea() {
private _bulkCreateArea = () => {
showAreaRegistryDetailDialog(this, {
createEntry: async (values) => {
const area = await createAreaRegistryEntry(this.hass, values);
@@ -1248,7 +1248,7 @@ ${rejected
return area;
},
});
}
};
private _handleSortingChanged(ev: CustomEvent) {
this._activeSorting = ev.detail;