Bug 1631577 - Fix Cannot delete entries within Customize Headers. r=mkmelin a=wsmwk
authorKhushil Mistry <khushil324@gmail.com>
Wed, 13 May 2020 16:47:15 +1200
changeset 39041 d09a306ef3a070a0acb80be27d36e8908ba31c9a
parent 39040 f3ae070191f10b7281025a43d69285bf769042d6
child 39042 d65fd3e8bcf52ba68e09e8099976fb869320387c
push id401
push userclokep@gmail.com
push dateMon, 01 Jun 2020 20:41:59 +0000
reviewersmkmelin, wsmwk
bugs1631577
Bug 1631577 - Fix Cannot delete entries within Customize Headers. r=mkmelin a=wsmwk
mailnews/base/search/content/CustomHeaders.js
mailnews/base/search/content/searchWidgets.js
--- a/mailnews/base/search/content/CustomHeaders.js
+++ b/mailnews/base/search/content/CustomHeaders.js
@@ -148,33 +148,25 @@ function duplicateHdrExists(hdr) {
 }
 
 function onRemoveHeader() {
   var listitem = gHdrsList.selectedItems[0];
   if (!listitem) {
     return;
   }
   listitem.remove();
-  var selectedHdr = GetListItemAttributeStr(listitem);
+  var selectedHdr = listitem.firstElementChild.getAttribute("value").trim();
   for (let i = 0; i < gArrayHdrs.length; i++) {
     if (gArrayHdrs[i] == selectedHdr) {
       gArrayHdrs.splice(i, 1);
       break;
     }
   }
 }
 
-function GetListItemAttributeStr(listitem) {
-  if (listitem) {
-    return TrimString(listitem.getAttribute("label"));
-  }
-
-  return "";
-}
-
 function addRow(newHdr) {
   return gHdrsList.appendItem(newHdr, "");
 }
 
 function updateAddButton(aDisable) {
   // only update the button if the disabled state changed
   if (aDisable == gAddButton.disabled) {
     return;
--- a/mailnews/base/search/content/searchWidgets.js
+++ b/mailnews/base/search/content/searchWidgets.js
@@ -472,20 +472,23 @@
           args
         );
         // User may have removed the custom header currently selected
         // in the menulist so temporarily set the selection to a safe value.
         this.value = Ci.nsMsgSearchAttrib.OtherHeader;
         // rebuild the menulist
         UpdateAfterCustomHeaderChange();
         // Find the created or chosen custom header and select it.
+        let menuitem = null;
         if (args.selectedVal) {
-          let menuitem = this.menulist.querySelector(
+          menuitem = this.menulist.querySelector(
             `[label="${args.selectedVal}"]`
           );
+        }
+        if (menuitem) {
           this.value = menuitem.value;
         } else {
           // Nothing was picked in the custom headers editor so just pick something
           // instead of the current "Customize" menuitem.
           this.value = this.menulist.getItemAtIndex(0).value;
         }
       } else {
         this.value = this.menulist.value;