Skip to content

Commit 3537057

Browse files
authored
Merge pull request #1700 from Grandi0z/cypht-fix-focus-mangement-for-compose-page
fix(frontend): enhance focus management for compose page based on email scenario
2 parents e50a877 + 97d25e5 commit 3537057

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

modules/smtp/js_modules/route_handlers.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,24 @@ function applySmtpComposePageHandlers() {
195195
if ($('.compose_cc').val() || $('.compose_bcc').val()) {
196196
toggle_recip_flds();
197197
}
198+
// Handle focus management for different compose scenarios
198199
if (window.location.href.search('&reply=1') !== -1 || window.location.href.search('&reply_all=1') !== -1) {
199200
replace_cursor_positon ($('textarea[name="compose_body"]'));
200201
}
201-
if (window.location.href.search('&forward=1') !== -1) {
202+
else if (window.location.href.search('&forward=1') !== -1) {
203+
replace_cursor_positon ($('textarea[name="compose_body"]'));
202204
setTimeout(function() {
203205
save_compose_state();
204206
}, 100);
205207
}
208+
else {
209+
var toField = $('.compose_to');
210+
if (toField.val().trim() === '') {
211+
toField.focus();
212+
} else {
213+
$('textarea[name="compose_body"]').focus();
214+
}
215+
}
206216
if ($('.sys_messages').text() != 'Message Sent') {
207217
get_smtp_profile($('.compose_server').val());
208218
}

0 commit comments

Comments
 (0)