From 6cd2d3ef64f43bc4b790f2548738c030c7a56850 Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 11 Mar 2024 09:13:19 -0600 Subject: [PATCH] Et2Email: Fix search result required 2 down arrows to get result #2 --- api/js/etemplate/Et2Email/Et2Email.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/api/js/etemplate/Et2Email/Et2Email.ts b/api/js/etemplate/Et2Email/Et2Email.ts index 0ebc132f21..1a0d50bc58 100644 --- a/api/js/etemplate/Et2Email/Et2Email.ts +++ b/api/js/etemplate/Et2Email/Et2Email.ts @@ -374,9 +374,9 @@ export class Et2Email extends Et2InputWidget(LitElement) implements SearchMixinI }); // Select the target option + this.currentOption = option; if(option) { - this.currentOption = option; option.current = true; option.tabIndex = 0; option.focus(); @@ -880,11 +880,9 @@ export class Et2Email extends Et2InputWidget(LitElement) implements SearchMixinI { if(!this.open) { - this.show(); + return this.show(); } - event.stopPropagation(); - this.setCurrentOption(this._suggestions[0]); - return; + return this.handleSuggestionsKeyDown(event); } // Tab or enter checks current value else if(Et2Email.TAG_BREAK.indexOf(event.key) !== -1) @@ -1042,8 +1040,9 @@ export class Et2Email extends Et2InputWidget(LitElement) implements SearchMixinI handleSuggestionsKeyDown(event : KeyboardEvent) { // Select the option - const value = (this.currentOption.value).replaceAll("___", " "); - if(this.currentOption && ["ArrowRight", " ", ...Et2Email.TAG_BREAK].includes(event.key) && this.addAddress(value)) + if(this.currentOption && ["ArrowRight", " ", ...Et2Email.TAG_BREAK].includes(event.key) && + this.addAddress((this.currentOption.value).replaceAll("___", " ")) + ) { if(this._close_on_select) {