Bug 1609894 - Prevent prematurely creating addressing pills when typing commas on invalid address. r=mkmelin
authorAlessandro Castellani <alessandro@thunderbird.net>
Wed, 19 Feb 2020 09:08:05 -0800
changeset 37383 1d6c19070bffe7689241ac8e0612736bca76d484
parent 37382 7a9663e64dc8fa84e4dc2d5c11918add1a5aa457
child 37384 306ac4b77c679440f825d487a9147544591db953
push id2566
push userclokep@gmail.com
push dateMon, 09 Mar 2020 19:20:31 +0000
treeherdercomm-beta@a352facfa0a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs1609894
Bug 1609894 - Prevent prematurely creating addressing pills when typing commas on invalid address. r=mkmelin
mail/components/compose/content/addressingWidgetOverlay.js
--- a/mail/components/compose/content/addressingWidgetOverlay.js
+++ b/mail/components/compose/content/addressingWidgetOverlay.js
@@ -526,16 +526,20 @@ function recipientKeyPress(event, elemen
         let previous = element.previousElementSibling;
         if (previous && previous.tagName == "mail-address-pill") {
           document.getElementById("recipientsContainer").selectPills(previous);
           previous.focus();
         }
       }
       break;
     case ",":
+      // Don't trigger autocomplete if the typed value is not a valid address.
+      if (!isValidAddress(element.value)) {
+        return;
+      }
       event.preventDefault();
       element.handleEnter(event);
       break;
     case "Home":
     case "ArrowLeft":
     case "Backspace":
       if (!element.value && !event.repeat) {
         let pills = element