From 29b91301a65e2825afc415a60e1eab73d0de6d86 Mon Sep 17 00:00:00 2001
From: Christopher Speller <crspeller@gmail.com>
Date: Mon, 2 May 2016 08:08:05 -0400
Subject: Closing 'RHS' on mobile when jump link is clicked (#2825)

---
 webapp/components/search_results_item.jsx | 32 +++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)

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

diff --git a/webapp/components/search_results_item.jsx b/webapp/components/search_results_item.jsx
index 58f09c0e0..85d069dbc 100644
--- a/webapp/components/search_results_item.jsx
+++ b/webapp/components/search_results_item.jsx
@@ -6,13 +6,15 @@ import UserProfile from './user_profile.jsx';
 import UserStore from 'stores/user_store.jsx';
 
 import * as GlobalActions from 'action_creators/global_actions.jsx';
+import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
 import * as TextFormatting from 'utils/text_formatting.jsx';
 import * as Utils from 'utils/utils.jsx';
 import Constants from 'utils/constants.jsx';
+const ActionTypes = Constants.ActionTypes;
 
 import {FormattedMessage, FormattedDate} from 'react-intl';
 import React from 'react';
-import {Link} from 'react-router';
+import {browserHistory} from 'react-router';
 
 export default class SearchResultsItem extends React.Component {
     constructor(props) {
@@ -105,15 +107,37 @@ export default class SearchResultsItem extends React.Component {
                                     </time>
                                 </li>
                                 <li>
-                                    <Link
-                                        to={'/' + window.location.pathname.split('/')[1] + '/pl/' + post.id}
+                                    <a
+                                        onClick={
+                                            () => {
+                                                if (Utils.isMobile()) {
+                                                    AppDispatcher.handleServerAction({
+                                                        type: ActionTypes.RECEIVED_SEARCH,
+                                                        results: null
+                                                    });
+
+                                                    AppDispatcher.handleServerAction({
+                                                        type: ActionTypes.RECEIVED_SEARCH_TERM,
+                                                        term: null,
+                                                        do_search: false,
+                                                        is_mention_search: false
+                                                    });
+
+                                                    AppDispatcher.handleServerAction({
+                                                        type: ActionTypes.RECEIVED_POST_SELECTED,
+                                                        postId: null
+                                                    });
+                                                }
+                                                browserHistory.push('/' + window.location.pathname.split('/')[1] + '/pl/' + post.id);
+                                            }
+                                        }
                                         className='search-item__jump'
                                     >
                                         <FormattedMessage
                                             id='search_item.jump'
                                             defaultMessage='Jump'
                                         />
-                                    </Link>
+                                    </a>
                                 </li>
                                 <li>
                                     <a
-- 
cgit v1.2.3-1-g7c22

