mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-08 02:19:43 +00:00
Add trigger/condition/action dialog: select single search result with enter key (#27825)
* Add trigger/condition/action dialog: select single search result with enter key * Update src/panels/config/automation/add-automation-element-dialog.ts --------- Co-authored-by: Petar Petrov <MindFreeze@users.noreply.github.com>
This commit is contained in:
@@ -1054,6 +1054,7 @@ class DialogAddAutomationElement
|
||||
private _onSearchFocus(ev) {
|
||||
this._removeKeyboardShortcuts = tinykeys(ev.target, {
|
||||
ArrowDown: this._focusSearchList,
|
||||
Enter: this._pickSingleItem,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1070,6 +1071,39 @@ class DialogAddAutomationElement
|
||||
this._itemsListFirstElement.focus();
|
||||
};
|
||||
|
||||
private _pickSingleItem = (ev: KeyboardEvent) => {
|
||||
if (!this._filter) {
|
||||
return;
|
||||
}
|
||||
|
||||
ev.preventDefault();
|
||||
const automationElementType = this._params!.type;
|
||||
|
||||
const items = [
|
||||
...this._getFilteredItems(
|
||||
automationElementType,
|
||||
this._filter,
|
||||
this.hass.localize,
|
||||
this.hass.services,
|
||||
this._manifests
|
||||
),
|
||||
...(automationElementType !== "trigger"
|
||||
? this._getFilteredBuildingBlocks(
|
||||
automationElementType,
|
||||
this._filter,
|
||||
this.hass.localize
|
||||
)
|
||||
: []),
|
||||
];
|
||||
|
||||
if (items.length !== 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._params!.add(items[0].key);
|
||||
this.closeDialog();
|
||||
};
|
||||
|
||||
static get styles(): CSSResultGroup {
|
||||
return [
|
||||
css`
|
||||
|
||||
Reference in New Issue
Block a user