SearchMixin: If user enters a valid free entry then changes focus without pressing Tab or Enter key, accept the free entry

This commit is contained in:
nathan 2022-12-01 14:15:40 -07:00
parent 0ecfdd8bdf
commit 404a29b985

View File

@ -789,9 +789,15 @@ export const Et2WithSearchMixin = <T extends Constructor<LitElement>>(superclass
async _handleSearchBlur(event : FocusEvent)
{
clearTimeout(this._searchTimeout);
if(event.relatedTarget && this !== (<Element>event.relatedTarget).parentElement)
if(event.relatedTarget && this !== (<Element>event.relatedTarget).parentElement || event.relatedTarget === null)
{
// Try any value they had in progress
if(this._searchInputNode.value && this.allowFreeEntries)
{
this.createFreeEntry(this._searchInputNode.value);
}
await this.dropdown.hide();
this.clearSearch();
if(event.relatedTarget && event.relatedTarget !== this)
{
event.relatedTarget.focus();