Bug 1613284 - followup - only do focus changes when the shown/hidden status changed. rs=bustage-fix
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Fri, 27 Mar 2020 18:51:59 +0200
changeset 38587 a583705f483a880510bb8f0bf24285c45335daf4
parent 38586 1fdaf757efec965745f2c42072fc84451fc8426e
child 38588 3bc67467675b7d2d1a244578bb43ce345acc9d45
push id400
push userclokep@gmail.com
push dateMon, 04 May 2020 18:56:09 +0000
reviewersbustage-fix
bugs1613284
Bug 1613284 - followup - only do focus changes when the shown/hidden status changed. rs=bustage-fix
mail/components/compose/content/MsgComposeCommands.js
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -6200,28 +6200,35 @@ function toggleAttachmentPane(aAction = 
   let attachmentsBox = document.getElementById("attachments-box");
   let attachmentBucketSizer = document.getElementById("attachmentbucket-sizer");
 
   if (aAction == "toggle") {
     aAction = attachmentsBox.collapsed ? "show" : "hide";
   }
 
   switch (aAction) {
-    case "show":
+    case "show": {
+      let shown = !attachmentsBox.collapsed;
       attachmentsBox.collapsed = false;
       attachmentBucketSizer.collapsed = false;
       attachmentBucketSizer.setAttribute("state", "");
-      bucket.focus();
+      if (shown) {
+        bucket.focus();
+      }
       break;
-
-    case "hide":
-      SetMsgBodyFrameFocus();
+    }
+
+    case "hide": {
+      if (document.activeElement == bucket) {
+        SetMsgBodyFrameFocus();
+      }
       attachmentsBox.collapsed = true;
       attachmentBucketSizer.setAttribute("state", "collapsed");
       break;
+    }
   }
   for (let menuitem of document.querySelectorAll(
     'menuitem[command="cmd_toggleAttachmentPane"]'
   )) {
     menuitem.checked = aAction == "show";
   }
 }