From 81e55f8033dd3389dc95cd132ef4699705414b23 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 26 Feb 2020 20:16:12 +0100 Subject: [PATCH] Elastic: Fix recipient input bug when using click to select a contact from autocomplete list (#7231) --- CHANGELOG | 1 + program/js/app.js | 2 +- skins/elastic/ui.js | 14 ++++++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1bfb2d7e0..7488a44d1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ CHANGELOG Roundcube Webmail - Fix bug where attachments with Content-Id were attached to the message on reply (#7122) - Fix identity selection on reply when both sender and recipient addresses are included in identities (#7211) - Elastic: Fix text selection with Shift+PageUp and Shift+PageDown in plain text editor when using Chrome (#7230) +- Elastic: Fix recipient input bug when using click to select a contact from autocomplete list (#7231) RELEASE 1.4.3 ------------- diff --git a/program/js/app.js b/program/js/app.js index d470fdccf..9c0517469 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -6081,7 +6081,7 @@ function rcube_webmail() this.set_caret_pos(input, p + to.length); // run onchange action on the element - $(input).change(); + $(input).trigger('change', [true]); }; this.ksearch_click = function(node) diff --git a/skins/elastic/ui.js b/skins/elastic/ui.js index 606cfbaa2..e63f6b225 100644 --- a/skins/elastic/ui.js +++ b/skins/elastic/ui.js @@ -3173,8 +3173,8 @@ function rcube_elastic_ui() return result.recipients.length > 0; }, - parse_func = function(e) { - var paste, value = this.value; + parse_func = function(e, ac) { + var last, paste, value = this.value; // On paste the text is not yet in the input we have to use clipboard. // Also because on paste new-line characters are replaced by spaces (#6460) @@ -3185,6 +3185,16 @@ function rcube_elastic_ui() value = value.substring(0, this.selectionStart) + paste + value.substring(this.selectionEnd); e.preventDefault(); } + // #7231: When clicking on autocompletion list a change event + // is fired twice. We have to remove last recipient box if it is + // the same recpient (with incomplete email address). + // FIXME: Anyone with a better solution? + else if (ac) { + last = list.find('li.recipient').last(); + if (last.length && this.value.indexOf(last.text().replace(/[ ,]+$/, '')) > -1) { + last.remove(); + } + } update_func(value); },