Bug 1488721 - Prevent closing the popup menu by clicking the space of tooltip popup menu. r=birtles
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Thu, 18 Oct 2018 05:48:55 +0000
changeset 500319 7e125b229e2990eeeae27927415ca5ea4a9ed77e
parent 500318 32cff4bae8200974970704733601e14345058a6f
child 500320 2dd8df3604ef3a4130daea876a25efe6db16536f
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs1488721
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1488721 - Prevent closing the popup menu by clicking the space of tooltip popup menu. r=birtles Differential Revision: https://phabricator.services.mozilla.com/D9059
devtools/client/shared/components/menu/MenuButton.js
--- a/devtools/client/shared/components/menu/MenuButton.js
+++ b/devtools/client/shared/components/menu/MenuButton.js
@@ -9,16 +9,17 @@
 
 const Services = require("Services");
 const flags = require("devtools/shared/flags");
 const { createRef, PureComponent } = require("devtools/client/shared/vendor/react");
 const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
 const dom = require("devtools/client/shared/vendor/react-dom-factories");
 const { button } = dom;
 const { HTMLTooltip } = require("devtools/client/shared/widgets/tooltip/HTMLTooltip");
+const { focusableSelector } = require("devtools/client/shared/focus");
 
 const isMacOS = Services.appinfo.OS === "Darwin";
 
 loader.lazyRequireGetter(this, "createPortal", "devtools/client/shared/vendor/react-dom", true);
 
 // Return a copy of |obj| minus |fields|.
 const omit = (obj, fields) => {
   const objCopy = { ...obj };
@@ -308,17 +309,19 @@ class MenuButton extends PureComponent {
           this.forceUpdate();
         }
       }
     // If we clicked one of the menu items, then, by default, we should
     // auto-collapse the menu.
     //
     // We check for the defaultPrevented state, however, so that menu items can
     // turn this behavior off (e.g. a menu item with an embedded button).
-    } else if (this.state.expanded && !e.defaultPrevented) {
+    } else if (this.state.expanded &&
+               !e.defaultPrevented &&
+               e.target.matches(focusableSelector)) {
       this.hideMenu();
     }
   }
 
   onKeyDown(e) {
     if (!this.state.expanded) {
       return;
     }