Focus on "To:" for new messages, body for replies.
authorArt Cancro <ajc@citadel.org>
Tue, 21 Nov 2023 23:26:46 +0000 (18:26 -0500)
committerArt Cancro <ajc@citadel.org>
Tue, 21 Nov 2023 23:26:46 +0000 (18:26 -0500)
webcit-ng/static/js/view_mail.js

index e44a73a032990786b07f11793f48ceebb0f85f6d..cb0e3814a101d3fabe73c69a439d14a6f2049e64 100644 (file)
@@ -431,8 +431,12 @@ function render_mailbox_display(notify) {
 
 // Compose a new mail message (called by the Reply button here, or by the dispatcher in views.js)
 function mail_compose(is_quoted, references, quoted_msgnum, m_to, m_cc, m_subject) {
+
+       let is_reply = 0;
+
        // m_to will be an array of zero or more recipients for the To: field.  Convert it to a string.
        if (m_to) {
+               is_reply = 1;
                m_to = Array.from(new Set(m_to));       // remove dupes
                m_to_str = "";
                for (i=0; i<m_to.length; ++i) {
@@ -448,6 +452,7 @@ function mail_compose(is_quoted, references, quoted_msgnum, m_to, m_cc, m_subjec
 
        // m_to will be an array of zero or more recipients for the Cc: field.  Convert it to a string.
        if (m_cc) {
+               is_reply = 1;
                m_cc = Array.from(new Set(m_cc));       // remove dupes
                m_cc_str = "";
                for (i=0; i<m_cc.length; ++i) {
@@ -535,7 +540,13 @@ function mail_compose(is_quoted, references, quoted_msgnum, m_to, m_cc, m_subjec
                mail_display_message(quoted_msgnum, document.getElementById(quoted_div_name), 0);
        }
 
-       setTimeout(() => { document.getElementById("ctdl-editor-body").focus(); }, 0);
+       if (is_reply) {
+               setTimeout(() => { document.getElementById("ctdl-editor-body").focus(); }, 0);
+       }
+       else {
+               setTimeout(() => { document.getElementById("ctdl-compose-to-field").focus(); }, 0);
+       }
+
 }
 
 // Called when the user clicks the button to make the hidden "CC" and "BCC" lines appear.