Bug 1490358 - Hide menu popup when press the ctrl+t. r=birtles

If push the ctrl+t, browser will open the new tab. In this case,
the XUL popup panel doesn't hide automatically(autohide=false).
As the result of it, the popup menu will be displayed in the new tab
content. So this patch will hide the popup when receiving the ctr+t
shortcut in the MenuButton.

Differential Revision: https://phabricator.services.mozilla.com/D8809

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mantaroh Yoshinaga 2018-10-16 07:13:04 +00:00
parent d5a153395f
commit 856268ab66

View File

@ -15,6 +15,8 @@ const dom = require("devtools/client/shared/vendor/react-dom-factories");
const { button } = dom;
const { HTMLTooltip } = require("devtools/client/shared/widgets/tooltip/HTMLTooltip");
const isMacOS = Services.appinfo.OS === "Darwin";
loader.lazyRequireGetter(this, "createPortal", "devtools/client/shared/vendor/react-dom", true);
// Return a copy of |obj| minus |fields|.
@ -346,6 +348,16 @@ class MenuButton extends PureComponent {
}
}
break;
case "t":
if (isMacOS && e.metaKey || !isMacOS && e.ctrlKey) {
// Close the menu if the user opens a new tab while it is still open.
//
// Bug 1499271: Once toolbox has been converted to XUL we should watch
// for the 'visibilitychange' event instead of explicitly looking for
// Ctrl+T.
this.hideMenu();
}
break;
}
}