From dadb6b86c3cdeead0e9443b2b595a3eb94fbf7f3 Mon Sep 17 00:00:00 2001 From: Sergey Mosin Date: Mon, 31 Jul 2023 16:50:00 -0400 Subject: [PATCH] improve: address input: space character can trigger '_parseValue' if the email address looks complete --- dev/Component/EmailAddresses.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dev/Component/EmailAddresses.js b/dev/Component/EmailAddresses.js index 70db0536d..1f7646c74 100644 --- a/dev/Component/EmailAddresses.js +++ b/dev/Component/EmailAddresses.js @@ -165,7 +165,9 @@ export class EmailAddressesComponent { _parseInput(force) { let val = this.input.value; - if ((force || val.includes(',') || val.includes(';')) && this._parseValue(val)) { + if ((force || val.includes(',') || val.includes(';') + || (val.charAt(val.length-1)===' ' && this._simpleEmailMatch(val))) + && this._parseValue(val)) { this.input.value = ''; } this._resizeInput(); @@ -284,6 +286,13 @@ export class EmailAddressesComponent { } } + _simpleEmailMatch(value) { + // A very SIMPLE test to check if the value might be an email + const val = value.trim(); + return /^[^@]*<[^\s@]{1,128}@[^\s@]{1,256}\.[\w]{2,32}>$/g.test(val) + || /^[^\s@]{1,128}@[^\s@]{1,256}\.[\w]{2,32}$/g.test(val); + } + _renderTags() { let self = this; [...self.ul.children].forEach(node => node !== self.inputCont && node.remove());