Bug 1538520 - make 'Enabled' filter property in filter list stick by properly checking the state of the checkbox. r=darktrojan a=jorgk
authoraceman <acelists@atlas.sk>
Sat, 23 Mar 2019 17:17:00 +0100
changeset 33962 6360477e63b5
parent 33961 26606ff7a3f6
child 33963 ff526625abe9
push id2393
push usermozilla@jorgk.com
push dateMon, 25 Mar 2019 10:52:11 +0000
treeherdercomm-beta@009e7920f860 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdarktrojan, jorgk
bugs1538520
Bug 1538520 - make 'Enabled' filter property in filter list stick by properly checking the state of the checkbox. r=darktrojan a=jorgk
mail/base/content/FilterListDialog.js
--- a/mail/base/content/FilterListDialog.js
+++ b/mail/base/content/FilterListDialog.js
@@ -285,17 +285,17 @@ function toggleFilter(aFilterItem, aSetF
   if (filter.unparseable && !filter.enabled) {
     Services.prompt.alert(window, null, gFilterBundle.getString("cannotEnableFilter"));
     return;
   }
   filter.enabled = aSetForEvent === undefined ? !filter.enabled : aSetForEvent;
 
   // Now update the checkbox
   if (aSetForEvent === undefined) {
-    aFilterItem.firstChild.nextSibling.setAttribute("checked", filter.enabled);
+    aFilterItem.firstChild.nextSibling.checked = filter.enabled;
   }
   // For accessibility set the checked state on listitem
   aFilterItem.setAttribute("aria-checked", filter.enabled);
 }
 
 /**
  * Selects a specific filter in the filter list.
  * The listbox view is scrolled to the corresponding item.
@@ -708,17 +708,17 @@ function rebuildFilterList() {
       // If there are not enough listitems in the list, create a new one.
       listitem = document.createElement("richlistitem");
       listitem.setAttribute("align", "center");
       listitem.setAttribute("role", "checkbox");
       nameCell = document.createElement("label");
       nameCell.setAttribute("flex", "1");
       enabledCell = document.createElement("checkbox");
       enabledCell.setAttribute("style", "padding-inline-start: 25px;");
-      enabledCell.addEventListener("click", onFilterClick, true);
+      enabledCell.addEventListener("CheckboxStateChange", onFilterClick, true);
       listitem.appendChild(nameCell);
       listitem.appendChild(enabledCell);
       gFilterListbox.appendChild(listitem);
       // We have to attach this listener to the listitem, even though we only care
       // about clicks on the enabledCell. However, attaching to that item doesn't
       // result in any events actually getting received.
       listitem.addEventListener("dblclick", onFilterDoubleClick, true);
     }
@@ -853,22 +853,19 @@ function getServerThatCanHaveFilters() {
       if (currentServer.canHaveFilters)
         return currentServer;
     }
 
     return null;
 }
 
 function onFilterClick(event) {
-    // we only care about button 0 (left click) events
-    if (event.button != 0) {
-      return;
-    }
-
-    toggleFilter(this.parentNode, !this.checked);
+  // This is called after the clicked checkbox changed state
+  // so this.checked is the right state we want to toggle to.
+  toggleFilter(this.parentNode, this.checked);
 }
 
 function onFilterDoubleClick(event) {
     // we only care about button 0 (left click) events
     if (event.button != 0)
       return;
 
     onEditFilter();