Bug 1609901 - Remove unwanted whitespaces from compose message input fields. r=mkmelin
authorAlessandro Castellani <alessandro@thunderbird.net>
Sat, 01 Feb 2020 08:57:26 +0100
changeset 38054 10f51319aa7b20db37f41513ed737455a84dbd2c
parent 38053 79c715e3ece3ab58035b2a1fb0643632d9b7810d
child 38055 f7b29a032c0cab7a9f6b8d5a43de8440751e3c1b
push id398
push userclokep@gmail.com
push dateMon, 09 Mar 2020 19:10:28 +0000
reviewersmkmelin
bugs1609901
Bug 1609901 - Remove unwanted whitespaces from compose message input fields. r=mkmelin
mail/components/compose/content/addressingWidgetOverlay.js
--- a/mail/components/compose/content/addressingWidgetOverlay.js
+++ b/mail/components/compose/content/addressingWidgetOverlay.js
@@ -482,51 +482,52 @@ function getLoadContext() {
  *
  * @param {Event} event - The DOM keypress event.
  * @param {HTMLElement} element - The element that triggered the keypress event.
  */
 function recipientKeyPress(event, element) {
   switch (event.key) {
     case "a":
       // Select all the pills if the input is empty.
-      if ((event.ctrlKey || event.metaKey) && !element.value.trim()) {
+      if ((event.ctrlKey || event.metaKey) && !element.value) {
         let previous = element.previousElementSibling;
         if (previous && previous.tagName == "mail-address-pill") {
           document.getElementById("recipientsContainer").selectPills(previous);
           previous.focus();
         }
       }
       break;
     case ",":
       event.preventDefault();
       element.handleEnter(event);
       break;
     case "Home":
-    case "End":
     case "ArrowLeft":
     case "Backspace":
-      if (!element.value.trim() && !event.repeat) {
+      if (!element.value && !event.repeat) {
         let pills = element
           .closest(".address-container")
           .querySelectorAll("mail-address-pill");
         if (pills.length) {
           let key = event.key == "Home" ? 0 : pills.length - 1;
           pills[key].focus();
           document
             .getElementById("recipientsContainer")
             .checkKeyboardSelected(event, pills[key]);
         }
       }
       break;
     case "Enter":
-      // No address entered, move focus to Subject field.
+      // No address entered, trim input and move focus to the next available
+      // element.
       if (!element.value.trim()) {
+        element.value = "";
         event.stopPropagation();
         event.preventDefault();
-        document.getElementById("msgSubject").focus();
+        SetFocusOnNextAvailableElement(element);
       }
       break;
     case "Tab":
       // Trigger the autocomplete controller only if we have a value
       // to prevent interfering with the natural change of focus on Tab.
       if (element.value.trim()) {
         event.preventDefault();
         element.handleEnter(event);