From 9b48cd7737f6c8b17f00ed0f432854adf87adfd8 Mon Sep 17 00:00:00 2001 From: Wendelin <12148533+wendevlin@users.noreply.github.com> Date: Thu, 6 Nov 2025 14:46:53 +0100 Subject: [PATCH] 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 --- .../add-automation-element-dialog.ts | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/panels/config/automation/add-automation-element-dialog.ts b/src/panels/config/automation/add-automation-element-dialog.ts index 07e26abde0..96fd43225b 100644 --- a/src/panels/config/automation/add-automation-element-dialog.ts +++ b/src/panels/config/automation/add-automation-element-dialog.ts @@ -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`