Et2Email: Fix search result required 2 down arrows to get result #2

This commit is contained in:
nathan 2024-03-11 09:13:19 -06:00
parent d7e9a093b7
commit 6cd2d3ef64

View File

@ -374,9 +374,9 @@ export class Et2Email extends Et2InputWidget(LitElement) implements SearchMixinI
}); });
// Select the target option // Select the target option
this.currentOption = option;
if(option) if(option)
{ {
this.currentOption = option;
option.current = true; option.current = true;
option.tabIndex = 0; option.tabIndex = 0;
option.focus(); option.focus();
@ -880,11 +880,9 @@ export class Et2Email extends Et2InputWidget(LitElement) implements SearchMixinI
{ {
if(!this.open) if(!this.open)
{ {
this.show(); return this.show();
} }
event.stopPropagation(); return this.handleSuggestionsKeyDown(event);
this.setCurrentOption(this._suggestions[0]);
return;
} }
// Tab or enter checks current value // Tab or enter checks current value
else if(Et2Email.TAG_BREAK.indexOf(event.key) !== -1) else if(Et2Email.TAG_BREAK.indexOf(event.key) !== -1)
@ -1042,8 +1040,9 @@ export class Et2Email extends Et2InputWidget(LitElement) implements SearchMixinI
handleSuggestionsKeyDown(event : KeyboardEvent) handleSuggestionsKeyDown(event : KeyboardEvent)
{ {
// Select the option // Select the option
const value = (<string>this.currentOption.value).replaceAll("___", " "); if(this.currentOption && ["ArrowRight", " ", ...Et2Email.TAG_BREAK].includes(event.key) &&
if(this.currentOption && ["ArrowRight", " ", ...Et2Email.TAG_BREAK].includes(event.key) && this.addAddress(value)) this.addAddress((<string>this.currentOption.value).replaceAll("___", " "))
)
{ {
if(this._close_on_select) if(this._close_on_select)
{ {