From 968ff951393d9641f7c32c27824cb4a5345251c6 Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 18 Dec 2023 09:24:21 -0700 Subject: [PATCH] Et2Email: Show validation error for partially typed (not yet accepted) email addresses --- api/js/etemplate/Et2Email/Et2Email.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/api/js/etemplate/Et2Email/Et2Email.ts b/api/js/etemplate/Et2Email/Et2Email.ts index a06cb16353..f96bbc6b7e 100644 --- a/api/js/etemplate/Et2Email/Et2Email.ts +++ b/api/js/etemplate/Et2Email/Et2Email.ts @@ -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(); } };