Bug 1519328 - Do not focus attachment pane if an attachment is added via the keyboard. r+a=jorgk
authoraceman <acelists@atlas.sk>
Sun, 12 May 2019 21:17:32 +0200
changeset 32196 70ce813285f678f675a7ef2d83af7c4c82c47640
parent 32195 6dc568428c81f0eb85f345fedbfa5c473a60a601
child 32197 cd0440b2fedd3d5de4ee3f646f3c45eb4843a5b6
push id190
push usermozilla@jorgk.com
push dateSun, 12 May 2019 19:49:38 +0000
treeherdercomm-esr60@29e8a0eb1dcb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1519328
Bug 1519328 - Do not focus attachment pane if an attachment is added via the keyboard. r+a=jorgk
mail/components/compose/content/MsgComposeCommands.js
mail/test/mozmill/composition/test-focus.js
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -5252,17 +5252,17 @@ function toggleAttachmentPane(aAction = 
     }
   }
 
   switch (aAction) {
     case "show":
       attachmentsBox.collapsed = false;
       attachmentBucketSizer.collapsed = false;
       attachmentBucketSizer.setAttribute("state", "");
-      if (!bucketHasFocus)
+      if (!bucketHasFocus && eventSource == "key")
         bucket.focus();
       break;
 
     case "hide":
       if (bucketHasFocus)
         SetMsgBodyFrameFocus();
       attachmentsBox.collapsed = true;
       attachmentBucketSizer.setAttribute("state", "collapsed");
@@ -6185,16 +6185,18 @@ var envelopeDragObserver = {
 
         attachments.push(attachment);
       }
     }
 
     // Add attachments if any.
     if (attachments.length > 0)
       AddAttachments(attachments);
+
+    bucket.focus();
   },
 
   onDragOver: function (aEvent, aFlavour, aDragSession)
   {
     let bucket = document.getElementById("attachmentBucket");
     let dragSourceNode = aDragSession.sourceNode;
     if (dragSourceNode && dragSourceNode.parentNode == bucket) {
       // If we're dragging from the attachment bucket onto itself, we need to
--- a/mail/test/mozmill/composition/test-focus.js
+++ b/mail/test/mozmill/composition/test-focus.js
@@ -31,22 +31,16 @@ function check_element_cycling(controlle
   let subjectElement    = controller.e("msgSubject");
   let attachmentElement = controller.e("attachmentBucket");
   let contentElement    = controller.window.content;
   let identityElement   = controller.e("msgIdentity");
 
   let key = ctrlTab ? "VK_TAB" : "VK_F6";
 
   // We start on the addressing widget and go from there.
-  // If we added an attachment, the attachment bucket got focused so
-  // we need to fix this first.
-  if (attachmentsExpanded) {
-    assert_equals(attachmentElement, controller.window.WhichElementHasFocus());
-    controller.window.SetMsgAddressingWidgetTreeElementFocus();
-  }
 
   controller.keypress(null, key, {ctrlKey: ctrlTab});
   assert_equals(subjectElement, controller.window.WhichElementHasFocus());
   if (attachmentsExpanded) {
     controller.keypress(null, key, {ctrlKey: ctrlTab});
     assert_equals(attachmentElement, controller.window.WhichElementHasFocus());
   }
   controller.keypress(null, key, {ctrlKey: ctrlTab});