Bug 1574440 - Introduce shortcut for opening the Search Panel. r=Honza
authorlloan <lloanalas@outlook.com>
Fri, 23 Aug 2019 06:51:44 +0000
changeset 489542 8f8c3a9309967397ae28797c808f43898647334c
parent 489541 5381b061c01e087101b1364ff0bf657c5793c2a2
child 489543 30cefc7ac14735dd10f7a3ac696f3db001761039
push id36476
push userncsoregi@mozilla.com
push dateFri, 23 Aug 2019 15:36:51 +0000
treeherdermozilla-central@8f6e40f9a0ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza
bugs1574440
milestone70.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 1574440 - Introduce shortcut for opening the Search Panel. r=Honza Differential Revision: https://phabricator.services.mozilla.com/D43180
devtools/client/locales/en-US/netmonitor.properties
devtools/client/netmonitor/src/components/Toolbar.js
--- a/devtools/client/locales/en-US/netmonitor.properties
+++ b/devtools/client/locales/en-US/netmonitor.properties
@@ -867,16 +867,20 @@ netmonitor.toolbar.filter.other=Other
 # LOCALIZATION NOTE (netmonitor.toolbar.filterFreetext.label): This is the label
 # displayed in the network toolbar for the url filtering textbox.
 netmonitor.toolbar.filterFreetext.label=Filter URLs
 
 # LOCALIZATION NOTE (netmonitor.toolbar.filterFreetext.key): This is the
 # shortcut key to focus on the toolbar url filtering textbox
 netmonitor.toolbar.filterFreetext.key=CmdOrCtrl+F
 
+# LOCALIZATION NOTE (netmonitor.toolbar.search.key): This is the
+# shortcut key to toggle the search panel
+netmonitor.toolbar.search.key=CmdOrCtrl+Shift+F
+
 # LOCALIZATION NOTE (netmonitor.toolbar.filterFreetext.learnMore): This is
 # the title used for MDN icon in filtering textbox
 netmonitor.toolbar.filterFreetext.learnMore=Learn more about filtering
 
 # LOCALIZATION NOTE (netmonitor.toolbar.enablePersistentLogs.label): This is the label
 # displayed for the checkbox for enabling persistent logs.
 netmonitor.toolbar.enablePersistentLogs.label=Persist Logs
 
--- a/devtools/client/netmonitor/src/components/Toolbar.js
+++ b/devtools/client/netmonitor/src/components/Toolbar.js
@@ -22,34 +22,41 @@ const {
   getTypeFilteredRequests,
 } = require("../selectors/index");
 const {
   autocompleteProvider,
 } = require("../utils/filter-autocomplete-provider");
 const { L10N } = require("../utils/l10n");
 const { fetchNetworkUpdatePacket } = require("../utils/request-utils");
 
+loader.lazyRequireGetter(
+  this,
+  "KeyShortcuts",
+  "devtools/client/shared/key-shortcuts"
+);
+
 // MDN
 const { getFilterBoxURL } = require("../utils/mdn-utils");
 const LEARN_MORE_URL = getFilterBoxURL();
 
 // Components
 const NetworkThrottlingMenu = createFactory(
   require("devtools/client/shared/components/throttling/NetworkThrottlingMenu")
 );
 const SearchBox = createFactory(
   require("devtools/client/shared/components/SearchBox")
 );
 
 const { button, div, input, label, span } = dom;
 
 // Localization
-const SEARCH_KEY_SHORTCUT = L10N.getStr(
+const FILTER_KEY_SHORTCUT = L10N.getStr(
   "netmonitor.toolbar.filterFreetext.key"
 );
+const SEARCH_KEY_SHORTCUT = L10N.getStr("netmonitor.toolbar.search.key");
 const SEARCH_PLACE_HOLDER = L10N.getStr(
   "netmonitor.toolbar.filterFreetext.label"
 );
 const TOOLBAR_CLEAR = L10N.getStr("netmonitor.toolbar.clear");
 const TOOLBAR_TOGGLE_RECORDING = L10N.getStr(
   "netmonitor.toolbar.toggleRecording"
 );
 const TOOLBAR_SEARCH = L10N.getStr("netmonitor.toolbar.search");
@@ -158,16 +165,24 @@ class Toolbar extends Component {
     Services.prefs.addObserver(
       DEVTOOLS_ENABLE_PERSISTENT_LOG_PREF,
       this.updatePersistentLogsEnabled
     );
     Services.prefs.addObserver(
       DEVTOOLS_DISABLE_CACHE_PREF,
       this.updateBrowserCacheDisabled
     );
+
+    this.shortcuts = new KeyShortcuts({
+      window,
+    });
+
+    this.shortcuts.on(SEARCH_KEY_SHORTCUT, event => {
+      this.props.toggleSearchPanel();
+    });
   }
 
   shouldComponentUpdate(nextProps) {
     return (
       this.props.persistentLogsEnabled !== nextProps.persistentLogsEnabled ||
       this.props.browserCacheDisabled !== nextProps.browserCacheDisabled ||
       this.props.recording !== nextProps.recording ||
       this.props.searchPanelOpen !== nextProps.searchPanelOpen ||
@@ -426,17 +441,17 @@ class Toolbar extends Component {
   }
 
   /**
    * Render filter Searchbox.
    */
   renderFilterBox(setRequestFilterText) {
     return SearchBox({
       delay: FILTER_SEARCH_DELAY,
-      keyShortcut: SEARCH_KEY_SHORTCUT,
+      keyShortcut: FILTER_KEY_SHORTCUT,
       placeholder: SEARCH_PLACE_HOLDER,
       type: "filter",
       ref: "searchbox",
       onChange: setRequestFilterText,
       onFocus: this.onSearchBoxFocus,
       autocompleteProvider: this.autocompleteProvider,
       learnMoreUrl: LEARN_MORE_URL,
       learnMoreTitle: LEARN_MORE_TITLE,