Bug 1667173 - Fix recipients area growing horizontally when addresses are dragged and dropped from the Contacts sidebar. r=mkmelin
authorAlessandro Castellani <alessandro@thunderbird.net>
Fri, 25 Sep 2020 12:05:57 +0300
changeset 30681 7c155c1b1aaf7882f60b0dc71f819023da88f4ae
parent 30680 eb083986f94a7a406eb2eec95ab4357866eec35a
child 30682 50afdb66a6dc47ac2596c7e8004f20e3affd6df3
push id17995
push usermkmelin@iki.fi
push dateFri, 25 Sep 2020 09:41:08 +0000
treeherdercomm-central@bf85e2413821 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs1667173
Bug 1667173 - Fix recipients area growing horizontally when addresses are dragged and dropped from the Contacts sidebar. r=mkmelin
mail/base/content/mailWidgets.js
--- a/mail/base/content/mailWidgets.js
+++ b/mail/base/content/mailWidgets.js
@@ -2144,27 +2144,29 @@
             }
             // Focus on the close label.
             row.querySelector(".aw-firstColBox > label").focus();
           }
         });
 
       this.addEventListener("dragstart", event => {
         let targetPill = event.originalTarget.closest("mail-address-pill");
-        if (targetPill && !targetPill.hasAttribute("selected")) {
+        if (!targetPill) {
+          return;
+        }
+        if (!targetPill.hasAttribute("selected")) {
           for (let pill of this.getAllSelectedPills()) {
             // Deselect all previously selected pills if the drag action starts
             // from a non selected pill.
             pill.removeAttribute("selected");
           }
           targetPill.toggleAttribute("selected");
         }
         let selectedPills = this.getAllSelectedPills();
-        // Interrupt if no address pill is being dragged.
-        if (!selectedPills.length || !targetPill) {
+        if (!selectedPills.length) {
           return;
         }
         event.dataTransfer.effectAllowed = "move";
         event.dataTransfer.dropEffect = "move";
         event.dataTransfer.setData("text/pills", "pills");
         event.dataTransfer.setDragImage(targetPill, 50, 12);
       });
 
@@ -2208,16 +2210,23 @@
           addressRow
             .querySelector(".address-container")
             .classList.remove("drag-address-container");
         }
       });
 
       this.addEventListener("drop", event => {
         if (!event.dataTransfer.getData("text/pills")) {
+          // Bail out if the dropped data comes from the contacts sidebar.
+          // Those addresses will be added immediately added as pills and
+          // not go through the input field.
+          if (event.dataTransfer.types.includes("moz/abcard")) {
+            return;
+          }
+
           // A text string was dropped inside the input field therefore we need
           // to update its size to fit the new content.
           let input = event.originalTarget.closest(
             ".address-input[recipienttype]"
           );
           // Trigger this action only if the string was dropped exactly on the
           // <div> inside the input field.
           if (input) {