From 0d6dd52be600d5b32ad84c9d26720d36cd96bc3e Mon Sep 17 00:00:00 2001
From: Saturnino Abril <saturnino.abril@gmail.com>
Date: Mon, 5 Jun 2017 20:46:31 +0800
Subject: [PLT-6697] Added CTRL/CMD+SHIFT+K shortcut to open 'more direct
 messages' dialog (#6534)

* add keypress shortcut to open 'more direct messages' dialog

* removed duplicate e.preventDefault()

* add text description to /shortcuts output
---
 webapp/components/sidebar.jsx | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

(limited to 'webapp/components/sidebar.jsx')

diff --git a/webapp/components/sidebar.jsx b/webapp/components/sidebar.jsx
index 5674e8c75..0988101d8 100644
--- a/webapp/components/sidebar.jsx
+++ b/webapp/components/sidebar.jsx
@@ -68,6 +68,7 @@ export default class Sidebar extends React.Component {
         this.hideNewChannelModal = this.hideNewChannelModal.bind(this);
         this.showMoreDirectChannelsModal = this.showMoreDirectChannelsModal.bind(this);
         this.hideMoreDirectChannelsModal = this.hideMoreDirectChannelsModal.bind(this);
+        this.handleOpenMoreDirectChannelsModal = this.handleOpenMoreDirectChannelsModal.bind(this);
 
         this.createChannelElement = this.createChannelElement.bind(this);
         this.updateTitle = this.updateTitle.bind(this);
@@ -200,6 +201,11 @@ export default class Sidebar extends React.Component {
         this.showMoreDirectChannelsModal(args.startingUsers);
     }
 
+    handleOpenMoreDirectChannelsModal(e) {
+        e.preventDefault();
+        this.showMoreDirectChannelsModal();
+    }
+
     onChange() {
         if (this.state.currentTeam.id !== TeamStore.getCurrentId()) {
             ChannelStore.clear();
@@ -301,6 +307,8 @@ export default class Sidebar extends React.Component {
             ChannelActions.goToChannel(nextChannel);
             this.updateScrollbarOnChannelChange(nextChannel);
             this.isSwitchingChannel = false;
+        } else if (Utils.cmdOrCtrlPressed(e) && e.shiftKey && e.keyCode === Constants.KeyCodes.K) {
+            this.handleOpenMoreDirectChannelsModal(e);
         }
     }
 
@@ -681,10 +689,7 @@ export default class Sidebar extends React.Component {
             <li key='more'>
                 <a
                     href='#'
-                    onClick={(e) => {
-                        e.preventDefault();
-                        this.showMoreDirectChannelsModal();
-                    }}
+                    onClick={this.handleOpenMoreDirectChannelsModal}
                 >
                     <FormattedMessage
                         id='sidebar.moreElips'
-- 
cgit v1.2.3-1-g7c22

