Bug 1526765 - make dblclick on first message in closed thread keep the cell open state. r=pmorris DONTBUILD
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Fri, 10 Jan 2020 12:52:19 +0200
changeset 37926 be621c5c7cd39d8110eb6eb4d4ee6ee0552ffb99
parent 37925 fae5cbb0e5a6801b3c0bf4cc06edc99320fff867
child 37927 74fb2e349d4e09a6b5c956e4a5c83476ea23cc2c
push id398
push userclokep@gmail.com
push dateMon, 09 Mar 2020 19:10:28 +0000
reviewerspmorris
bugs1526765
Bug 1526765 - make dblclick on first message in closed thread keep the cell open state. r=pmorris DONTBUILD
mail/base/content/threadPane.js
--- a/mail/base/content/threadPane.js
+++ b/mail/base/content/threadPane.js
@@ -40,45 +40,40 @@ function ThreadPaneOnClick(event) {
   }
 
   if (treeCellInfo.col.id == "selectCol") {
     HandleSelectColClick(event, treeCellInfo.row);
     return;
   }
 
   // Grouped By Sort dummy header row non cycler column doubleclick toggles the
-  // thread's open/close state; tree.xml handles it. Cyclers are not currently
+  // thread's open/closed state; tree.js handles it. Cyclers are not currently
   // implemented in group header rows, a click/doubleclick there should
   // select/toggle thread state.
   if (gFolderDisplay.view.isGroupedByHeaderAtIndex(treeCellInfo.row)) {
     if (!treeCellInfo.col.cycler) {
       return;
     }
     if (event.detail == 1) {
       gFolderDisplay.selectViewIndex(treeCellInfo.row);
     }
     if (event.detail == 2) {
       gFolderDisplay.view.dbView.toggleOpenState(treeCellInfo.row);
     }
     event.stopPropagation();
     return;
   }
 
-  // If the cell is in a cycler column or if the user doubleclicked on the
-  // twisty, don't open the message in a new window.
+  // Cyclers and twisties respond to single clicks, not double clicks.
   if (
     event.detail == 2 &&
     !treeCellInfo.col.cycler &&
     treeCellInfo.childElt != "twisty"
   ) {
     ThreadPaneDoubleClick();
-    // Doubleclicking should not toggle the open/close state of the thread.
-    // This will happen if we don't prevent the event from bubbling to the
-    // default handler in tree.xml.
-    event.stopPropagation();
   } else if (treeCellInfo.col.id == "junkStatusCol") {
     MsgJunkMailInfo(true);
   } else if (
     treeCellInfo.col.id == "threadCol" &&
     !event.shiftKey &&
     (event.ctrlKey || event.metaKey)
   ) {
     gDBView.ExpandAndSelectThreadByIndex(treeCellInfo.row, true);
@@ -223,31 +218,31 @@ function ThreadPaneDoubleClick() {
   }
 }
 
 function ThreadPaneKeyDown(event) {
   if (event.keyCode != KeyEvent.DOM_VK_RETURN) {
     return;
   }
 
-  // Grouped By Sort dummy header row <enter> toggles the thread's open/close
-  // state. Let tree.xml handle it.
+  // Grouped By Sort dummy header row <enter> toggles the thread's open/closed
+  // state. Let tree.js handle it.
   if (
     gFolderDisplay.view.showGroupedBySort &&
     gFolderDisplay.treeSelection &&
     gFolderDisplay.treeSelection.count == 1 &&
     gFolderDisplay.view.isGroupedByHeaderAtIndex(
       gFolderDisplay.treeSelection.currentIndex
     )
   ) {
     return;
   }
 
   // Prevent any thread that happens to be last selected (currentIndex) in a
-  // single or multi selection from toggling in tree.xml.
+  // single or multi selection from toggling in tree.js.
   event.stopImmediatePropagation();
 
   ThreadPaneDoubleClick();
 }
 
 function MsgSortByThread() {
   gFolderDisplay.view.showThreaded = true;
   MsgSortThreadPane("byDate");
@@ -448,18 +443,29 @@ function GetThreadPaneFolder() {
 }
 
 function ThreadPaneOnLoad() {
   var tree = GetThreadTree();
   // We won't have the tree if we're in a message window, so exit silently
   if (!tree) {
     return;
   }
-
   tree.addEventListener("click", ThreadPaneOnClick, true);
+  tree.addEventListener(
+    "dblclick",
+    event => {
+      // The tree.js dblclick event handler is handling editing and toggling
+      // open state of the cell. We don't use editing, and we want to handle
+      // the toggling through the click handler (also for double click), so
+      // capture the dblclick event before it bubbles up and causes the
+      // tree.js dblclick handler to toggle open state.
+      event.stopPropagation();
+    },
+    true
+  );
 
   // The mousedown event listener below should only be added in the thread
   // pane of the mailnews 3pane window, not in the advanced search window.
   if (tree.parentNode.id == "searchResultListBox") {
     return;
   }
 
   tree.addEventListener("mousedown", TreeOnMouseDown, true);