From a3c491d5cb2d8ec64bdc5cb6eb67960e7ec563c0 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Mon, 7 Oct 2019 16:11:41 +0200 Subject: [PATCH] Elastic: Fix initial focus on recipients input in mail compose screen Also remove some redundant duplicated code --- CHANGELOG | 1 + program/js/app.js | 22 +++++++++++----------- skins/elastic/ui.js | 29 +++++++++++------------------ 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4685aafda..5d20244c4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ CHANGELOG Roundcube Webmail - Elastic: Resizeable columns (#6929) - Elastic: Fix position and style of auto-complete dropdown on small screens (#6951) +- Elastic: Fix initial focus on recipients input in mail compose screen - Redis: Improve error handling and phpredis 5.X support (#6888) - Fix bug where cache keys were not case-sensitive on MySQL/MSSQL (#6942) - Fix so an error is loogged when encryption fails (#6948) diff --git a/program/js/app.js b/program/js/app.js index 10475bd99..2c2dd3dcf 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -4578,22 +4578,14 @@ function rcube_webmail() // init autocomplete events on compose form inputs this.init_messageform_inputs = function(focused) { - var i, ac_props, + var i, input_to = $("[name='_to']"), ac_fields = ['cc', 'bcc', 'replyto', 'followupto']; - // configure parallel autocompletion - if (this.env.autocomplete_threads > 0) { - ac_props = { - threads: this.env.autocomplete_threads, - sources: this.env.autocomplete_sources - }; - } - // init live search events - this.init_address_input_events(input_to, ac_props); + this.init_address_input_events(input_to); for (i in ac_fields) { - this.init_address_input_events($("[name='_"+ac_fields[i]+"']"), ac_props); + this.init_address_input_events($("[name='_"+ac_fields[i]+"']")); } if (!focused) @@ -4674,6 +4666,14 @@ function rcube_webmail() this.init_address_input_events = function(obj, props) { + // configure parallel autocompletion + if (!props && this.env.autocomplete_threads > 0) { + props = { + threads: this.env.autocomplete_threads, + sources: this.env.autocomplete_sources + }; + } + obj.keydown(function(e) { return ref.ksearch_keydown(e, this, props); }) .attr({autocomplete: 'off', 'aria-autocomplete': 'list', 'aria-expanded': 'false', role: 'combobox'}); diff --git a/skins/elastic/ui.js b/skins/elastic/ui.js index 199073fb8..f8d71ed33 100644 --- a/skins/elastic/ui.js +++ b/skins/elastic/ui.js @@ -703,8 +703,8 @@ function rcube_elastic_ui() } } - // In compose/preview window we do not provide "Back' button, instead - // we modify the Mail button in the task menu to act like it (i.e. calls 'list' command) + // In compose/preview window we do not provide "Back" button, instead + // we modify the "Mail" button in the task menu to act like it (i.e. calls 'list' command) if (!rcmail.env.extwin && (rcmail.env.action == 'compose' || rcmail.env.action == 'show')) { $('a.mail', layout.menu).attr('onclick', "return rcmail.command('list','',this,event)"); } @@ -737,6 +737,10 @@ function rcube_elastic_ui() if (rcmail.env.devel_mode && window.less) { less.pageLoadFinished.then(function() { resize(); + // Re-focus the focused input field on mail compose + if (rcmail.env.compose_focus_elem) { + $(rcmail.env.compose_focus_elem).focus(); + } }); } else { @@ -3091,7 +3095,7 @@ function rcube_elastic_ui() */ function recipient_input(obj) { - var list, input, ac_props, + var list, input, input_len_update = function() { input.css('width', Math.max(40, input.val().length * 15 + 25)); }, @@ -3182,7 +3186,7 @@ function rcube_elastic_ui() .on('blur', function() { list.removeClass('focus'); }) .on('focus mousedown', function() { list.addClass('focus'); }); - list = $('