From b57c9fec89f736de8622218d6dc779012a266a91 Mon Sep 17 00:00:00 2001
From: enahum <nahumhbl@gmail.com>
Date: Thu, 8 Dec 2016 12:20:03 -0300
Subject: PLT-4894 channel switcher (CTRL+K) to match message autocomplete
 (#4733)

* PLT-4894 Change name display of direct messages in channel switcher (CTRL+K) to match message autocomplete

* Addressing feedback
---
 webapp/components/suggestion/suggestion_box.jsx | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

(limited to 'webapp/components/suggestion/suggestion_box.jsx')

diff --git a/webapp/components/suggestion/suggestion_box.jsx b/webapp/components/suggestion/suggestion_box.jsx
index 7f8bbf309..67a29fec3 100644
--- a/webapp/components/suggestion/suggestion_box.jsx
+++ b/webapp/components/suggestion/suggestion_box.jsx
@@ -152,6 +152,17 @@ export default class SuggestionBox extends React.Component {
             this.props.onChange(e);
         }
 
+        if (this.props.onItemSelected) {
+            const items = SuggestionStore.getItems(this.suggestionId);
+            const selection = SuggestionStore.getSelection(this.suggestionId);
+            for (const i of items) {
+                if (i.name === selection) {
+                    this.props.onItemSelected(i);
+                    break;
+                }
+            }
+        }
+
         textbox.focus();
 
         // set the caret position after the next rendering
@@ -199,6 +210,7 @@ export default class SuggestionBox extends React.Component {
 
         // Don't pass props used by SuggestionBox
         Reflect.deleteProperty(props, 'providers');
+        Reflect.deleteProperty(props, 'onItemSelected');
 
         const childProps = {
             ref: 'textbox',
@@ -280,5 +292,6 @@ SuggestionBox.propTypes = {
 
     // explicitly name any input event handlers we override and need to manually call
     onChange: React.PropTypes.func,
-    onKeyDown: React.PropTypes.func
+    onKeyDown: React.PropTypes.func,
+    onItemSelected: React.PropTypes.func
 };
-- 
cgit v1.2.3-1-g7c22

