Bug 1524210 - Only clear the richlistbox selection when the box itself is clicked if the richlistbox is of multiselection type. r=Gijs a=lizzard
authorJared Wein <jwein@mozilla.com>
Mon, 04 Feb 2019 22:14:57 +0000
changeset 515836 ee2b9d8d4b0b
parent 515835 b61d0fdc785b
child 515837 daa824c92e14
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, lizzard
bugs1524210
milestone66.0
Bug 1524210 - Only clear the richlistbox selection when the box itself is clicked if the richlistbox is of multiselection type. r=Gijs a=lizzard There are a couple ways to fix this specific bug in Preferences. We could expand the padding up to the start border and remove the margin, though there would still exist a 1px padding on the richlistbox. Historically this code, at least for Preferences, was impossible to hit. The scrollbox couldn't get clicked because its size was defined by an inner xul:box that was the size of the richlistitems and whatever margin they had. Clicking next to the richlistitems in the Preferences before this regression was a click on the anonymous box and thus didn't clear the selection. Another potential fix could be if we added a special attribute that doesn't allow deselecting if clicking into nothing, but that seems like a band-aid that we would end up using in many other places instead of just removing this behavior. Differential Revision: https://phabricator.services.mozilla.com/D18371
toolkit/content/widgets/richlistbox.js
--- a/toolkit/content/widgets/richlistbox.js
+++ b/toolkit/content/widgets/richlistbox.js
@@ -114,18 +114,19 @@ MozElements.RichListBox = class RichList
         } else {
           this._fireEvent(this.currentItem, "DOMMenuItemActive");
         }
       }
       this._lastKeyTime = 0;
     });
 
     this.addEventListener("click", event => {
-      // clicking into nothing should unselect
-      if (event.originalTarget == this) {
+      // clicking into nothing should unselect multiple selections
+      if (event.originalTarget == this &&
+          this.selType == "multiple") {
         this.clearSelection();
         this.currentItem = null;
       }
     });
 
     this.addEventListener("MozSwipeGesture", event => {
       // Only handle swipe gestures up and down
       switch (event.direction) {