Bug 1596681 - Clicking link in WhatsNew panel should honor Ctrl/Cmd to open link in background tab. r=jlast.
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Mon, 18 Nov 2019 08:39:24 +0000
changeset 502392 67811703c4d6a0ddab8e41d3682aaaf5c42b7dda
parent 502391 48919539e15c0417e8776dcbb6ef4cd3e1dd2301
child 502393 7b178028f4c487d16d8d8fc5c97b1f08992bdc32
push id36815
push usershindli@mozilla.com
push dateMon, 18 Nov 2019 16:17:29 +0000
treeherdermozilla-central@edad97097819 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlast
bugs1596681
milestone72.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 1596681 - Clicking link in WhatsNew panel should honor Ctrl/Cmd to open link in background tab. r=jlast. Differential Revision: https://phabricator.services.mozilla.com/D53157
devtools/client/whats-new/src/main.js
--- a/devtools/client/whats-new/src/main.js
+++ b/devtools/client/whats-new/src/main.js
@@ -2,16 +2,18 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
 
 "use strict";
 
 const ReactDOM = require("devtools/client/shared/vendor/react-dom");
 const Types = require("devtools/client/shared/vendor/react-prop-types");
 const { openDocLink } = require("devtools/client/shared/link");
+var Services = require("Services");
+const isMacOS = Services.appinfo.OS === "Darwin";
 
 const {
   Component,
   createFactory,
 } = require("devtools/client/shared/vendor/react");
 const dom = require("devtools/client/shared/vendor/react-dom-factories");
 
 const aside = {
@@ -92,33 +94,40 @@ const dev = {
     {
       header: `Debug Variables with Watchpoints`,
       description: `Debugger’s new Watchpoints feature lets you pause when properties get read or written. Right-click object properties in the Scopes pane when paused to use the new “Break on…” menu.`,
       href: `https://developer.mozilla.org/docs/Tools/Debugger/How_to/Set_a_watchpoint_on_a_property?utm_source=devtools&utm_medium=devtools_whatsnew`,
     },
   ],
 };
 
+function openLink(href, e) {
+  return openDocLink(href, {
+    relatedToCurrent: true,
+    inBackground: isMacOS ? e.metaKey : e.ctrlKey,
+  });
+}
+
 class Aside extends Component {
   render() {
     return dom.aside(
       {},
       dom.div(
         { className: "call-out" },
         dom.h3({}, aside.header),
         dom.p({}, aside.content),
         dom.p(
           { className: "cta" },
           dom.a(
             {
               href: aside.href,
               className: "devtools-button",
               onClick: e => {
                 e.preventDefault();
-                openDocLink(aside.href);
+                openLink(aside.href, e);
               },
             },
             aside.cta
           )
         )
       )
     );
   }
@@ -137,34 +146,34 @@ class Feature extends Component {
     const { header, description, href } = this.props;
     return dom.li(
       { key: header, className: "feature" },
       dom.a(
         {
           href,
           onClick: e => {
             e.preventDefault();
-            openDocLink(href);
+            openLink(href, e);
           },
         },
         dom.h3({}, header),
         dom.p({}, description)
       )
     );
   }
 }
 
 function Link(text, href) {
   return dom.a(
     {
       className: "link",
       href,
       onClick: e => {
         e.preventDefault();
-        openDocLink(href);
+        openLink(href, e);
       },
     },
     text
   );
 }
 
 class App extends Component {
   render() {