From be2e3f215412dcd8e92c04ce0df3a72a8293fd39 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Tue, 18 Jun 2019 16:25:20 +0200 Subject: [PATCH] Elastic: Fix handling new-line in text pasted to a recipient input --- CHANGELOG | 1 + skins/elastic/styles/widgets/forms.less | 2 +- skins/elastic/ui.js | 32 +++++-------------------- 3 files changed, 8 insertions(+), 27 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1077b34cc..ab2085405 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -27,6 +27,7 @@ CHANGELOG Roundcube Webmail - Elastic: Fix handling mailto: URL parameters in contact menu (#6751) - Elastic: Fix keyboard navigation in some menus, e.g. the contact menu - Elastic: Fix visual issue with long buttons in .boxwarning (#6797) +- Elastic: Fix handling new-line in text pasted to a recipient input - Larry: Fix regression where menu actions didn't work with keyboard (#6740) - ACL: Display user/group names (from ldap) instead of acl identifier - Password: Added ldap_exop driver (#4992) diff --git a/skins/elastic/styles/widgets/forms.less b/skins/elastic/styles/widgets/forms.less index bfbd2ab26..8a2694ab5 100644 --- a/skins/elastic/styles/widgets/forms.less +++ b/skins/elastic/styles/widgets/forms.less @@ -974,7 +974,7 @@ html.ms .propform { a.button.icon { font-size: .8em; cursor: pointer; - padding: 0 0 0 .25em; + padding: 0; &:before { float: none; diff --git a/skins/elastic/ui.js b/skins/elastic/ui.js index b778e4d93..36c63e4da 100644 --- a/skins/elastic/ui.js +++ b/skins/elastic/ui.js @@ -3061,7 +3061,7 @@ function rcube_elastic_ui() */ function recipient_input(obj) { - var list, input, ac_props, update_lock, + var list, input, ac_props, input_len_update = function() { input.css('width', Math.max(40, input.val().length * 15 + 25)); }, @@ -3069,9 +3069,6 @@ function rcube_elastic_ui() // update the original input $(obj).val(list.text() + input.val()); }, - focus_func = function() { - list.addClass('focus'); - }, insert_recipient = function(name, email, replace) { var recipient = $('
  • '), name_element = $('').html(recipient_input_name(name || email)) @@ -3102,12 +3099,6 @@ function rcube_elastic_ui() update_func = function(text) { var result; - if (update_lock) { - return; - } - - update_lock = true; - text = (text || input.val()).replace(/[,;\s]+$/, ''); result = recipient_input_parser(text); @@ -3121,31 +3112,19 @@ function rcube_elastic_ui() input.val(result.text); apply_func(); input_len_update(); - update_lock = false; }, 1); return result.recipients.length > 0; }, parse_func = function(e) { - if (e.type == 'blur') { - list.removeClass('focus'); - } - - // FIXME: This is a workaround for a bug where on a touch device - // selecting a recipient from autocomplete list do not work because - // of some events race condition (?) - if (this.value.indexOf('@') < 0) { - return; - } - // 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) - update_func(e.type == 'paste' ? (e.originalEvent.clipboardData || window.clipboardData).getData('text') : null); + update_func(e.type == 'paste' ? (e.originalEvent.clipboardData || window.clipboardData).getData('text') : this.value); }, keydown_func = function(e) { // On Backspace remove the last recipient if (e.keyCode == 8 && !input.val().length) { - list.children('li.recipient').first().remove(); + list.children('li.recipient').last().remove(); apply_func(); return false; } @@ -3161,10 +3140,11 @@ function rcube_elastic_ui() // Create the input element and "editable" area input = $('').attr({type: 'text', tabindex: $(obj).attr('tabindex')}) - .on('paste change blur', parse_func) + .on('paste change', parse_func) .on('input', input_len_update) // only to fix input length after paste .on('keydown', keydown_func) - .on('focus mousedown', focus_func); + .on('blur', function() { list.removeClass('focus'); }) + .on('focus mousedown', function() { list.addClass('focus'); }); list = $('
      ').addClass('form-control recipient-input') .append($('
    • ').append(input))