Bug 1530213 - Make invite attendees expand mailing lists. r=darktrojan BETA_68_CONTINUATION
authorBenjamin Flanagin <benjamin@thunderbird.net>
Mon, 08 Jul 2019 10:42:33 +0200
branchBETA_68_CONTINUATION
changeset 36061 be43f86e0509f04130b512f61ddbbe2777d2bcb2
parent 35641 8558829773989dd45ea74fab5829bdc661738f56
child 36062 f53a5e4487e6a27251cd7d45937edef39d05129e
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
reviewersdarktrojan
bugs1530213
Bug 1530213 - Make invite attendees expand mailing lists. r=darktrojan
calendar/base/content/dialogs/calendar-event-dialog-attendees-custom-elements.js
calendar/base/content/dialogs/calendar-event-dialog-attendees.js
--- a/calendar/base/content/dialogs/calendar-event-dialog-attendees-custom-elements.js
+++ b/calendar/base/content/dialogs/calendar-event-dialog-attendees-custom-elements.js
@@ -927,53 +927,58 @@ class MozCalendarEventAttendeesList exte
         input.attendee = newAttendee;
         input.value = entry;
         input.setAttribute("value", entry);
         input.setAttribute("dirty", "true");
         if (input.getAttribute("focused") != "") {
             input.removeAttribute("focused");
         }
 
-        let roleStatusIcon = listitem.querySelector(".status-icon");
+        let roleStatusIcon = listitem.querySelector(".status-icon, .role-icon");
         roleStatusIcon.removeAttribute("disabled");
         roleStatusIcon.setAttribute("class", "role-icon");
         roleStatusIcon.setAttribute("role", newAttendee.role);
 
         let userTypeIcon = listitem.querySelector(".usertype-icon");
         userTypeIcon.removeAttribute("disabled");
         userTypeIcon.setAttribute("cutype", newAttendee.userType);
     }
 
     /**
      * Resolves list.
      *
      * @param {Element} input       Node using which list has to be resolved.
      */
     resolvePotentialList(input) {
         let fieldValue = input.value;
-        if (input.id.length > 0 && fieldValue.length > 0) {
+        if (fieldValue) {
             let mailingList = this._resolveListByName(fieldValue);
             if (mailingList) {
                 let entries = this._getListEntries(mailingList);
                 if (entries.length > 0) {
-                    let currentIndex = parseInt(input.id.substr(13), 10);
+                    // `mMaxAttendees` holds the count of non-dummy rows, that is, rows
+                    // which have and icon and an email address or are ready to receive
+                    // an email address. By the time we get here, a new non-dummy row has
+                    // already been added, so the mailing list we want to expand is in the
+                    // row before the last row.
+                    let currentIndex = this.mMaxAttendees - 2;
                     let template = this.querySelector(".addressingWidgetItem");
                     let currentNode = template.parentNode.childNodes[currentIndex];
                     this._fillListItemWithEntry(currentNode, entries[0], currentIndex);
                     entries.shift();
                     let nextNode = template.parentNode.childNodes[currentIndex + 1];
                     currentIndex++;
                     for (let entry of entries) {
                         currentNode = template.cloneNode(true);
                         template.parentNode.insertBefore(currentNode, nextNode);
                         this._fillListItemWithEntry(currentNode, entry, currentIndex);
                         currentIndex++;
                     }
                     this.mMaxAttendees += entries.length;
-                    for (let i = currentIndex; i <= this.mMaxAttendees; i++) {
+                    for (let i = currentIndex; i < this.mMaxAttendees; i++) {
                         let row = template.parentNode.childNodes[i];
                         let textboxInput = row.querySelector(".textbox-addressingWidget");
                         textboxInput.setAttribute("dirty", "true");
                     }
                 }
             }
         }
     }
--- a/calendar/base/content/dialogs/calendar-event-dialog-attendees.js
+++ b/calendar/base/content/dialogs/calendar-event-dialog-attendees.js
@@ -871,18 +871,17 @@ function onAttrModified(event) {
     if (event.attrName == "width") {
         let selectionbar = document.getElementById("selection-bar");
         selectionbar.setWidth(selectionbar.getBoundingClientRect().width);
         return;
     }
 
     // Synchronize grid and attendee list
     let target = event.originalTarget;
-    if (target.hasAttribute("anonid") &&
-        target.getAttribute("anonid") == "input" &&
+    if (target.classList.contains("textbox-addressingWidget") &&
         event.attrName == "focused") {
         let attendees = document.getElementById("attendees-list");
         if (event.newValue == "true") {
             let grid = document.getElementById("freebusy-grid");
             if (grid.firstVisibleRow != attendees.firstVisibleRow) {
                 grid.firstVisibleRow = attendees.firstVisibleRow;
             }
         }