Et2Email: Show validation error for partially typed (not yet accepted) email addresses

This commit is contained in:
nathan 2023-12-18 09:24:21 -07:00
parent d28fbfeab3
commit c26b13986c

View File

@ -215,6 +215,7 @@ export class Et2Email extends Et2InputWidget(LitElement) implements SearchMixinI
this.open = false;
this._valueUID = this.egw().uid();
this.updateComplete.then(() => this.makeSortable());
document.addEventListener('focusin', this.handleLostFocus);
}
disconnectedCallback()
@ -225,6 +226,7 @@ export class Et2Email extends Et2InputWidget(LitElement) implements SearchMixinI
{
this._sortable.destroy();
}
document.removeEventListener('focusin', this.handleLostFocus);
}
willUpdate(changedProperties : PropertyValues)
@ -261,13 +263,11 @@ export class Et2Email extends Et2InputWidget(LitElement) implements SearchMixinI
private addOpenListeners()
{
document.addEventListener('focusin', this.handleLostFocus);
document.addEventListener('mousedown', this.handleLostFocus);
}
private removeOpenListeners()
{
document.removeEventListener('focusin', this.handleLostFocus);
document.removeEventListener('mousedown', this.handleLostFocus);
}
@ -594,6 +594,15 @@ export class Et2Email extends Et2InputWidget(LitElement) implements SearchMixinI
{
this._search.value = "";
}
else if(this._search.value)
{
// Invalid input, show message
// Can't just call this.validate() since the input is not part of the value
let currentValue = this.value;
this.value = [this._search.value];
this.validate();
this.value = currentValue;
}
this.hide();
}
};