Et2Email: When tabbing away with partial email typed, only accept current suggestion if it still matches

Previously current option was not updated fast enough, and was blindly accepted.
This commit is contained in:
nathan 2023-12-18 11:11:53 -07:00
parent c26b13986c
commit a348039716

View File

@ -448,6 +448,9 @@ export class Et2Email extends Et2InputWidget(LitElement) implements SearchMixinI
// Stop timeout timer // Stop timeout timer
clearTimeout(this._searchTimeout); clearTimeout(this._searchTimeout);
// Clear current option, it's probably going to go away
this.setCurrentOption(null);
this.searching = true; this.searching = true;
this.requestUpdate("searching"); this.requestUpdate("searching");
@ -699,7 +702,8 @@ export class Et2Email extends Et2InputWidget(LitElement) implements SearchMixinI
else if(Et2Email.TAG_BREAK.indexOf(event.key) !== -1) else if(Et2Email.TAG_BREAK.indexOf(event.key) !== -1)
{ {
// Check for valid email or current selection // Check for valid email or current selection
if(!this.validateAddress(this._search.value.trim()) && this.currentOption) if(!this.validateAddress(this._search.value.trim()) &&
this.currentOption && this.currentOption.value.toLowerCase().includes(this._search.value.toLowerCase()))
{ {
this._search.value = this.currentOption.value.replaceAll("___", " "); this._search.value = this.currentOption.value.replaceAll("___", " ");
} }