Closing 'RHS' on mobile when jump link is clicked (#2825)

Этот коммит содержится в:
Christopher Speller
2016-05-02 08:08:05 -04:00
родитель c63e027aec
Коммит 29b91301a6
2 изменённых файлов: 29 добавлений и 5 удалений

Просмотреть файл

@@ -6,13 +6,15 @@ import UserProfile from './user_profile.jsx';
import UserStore from 'stores/user_store.jsx'; import UserStore from 'stores/user_store.jsx';
import * as GlobalActions from 'action_creators/global_actions.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 TextFormatting from 'utils/text_formatting.jsx';
import * as Utils from 'utils/utils.jsx'; import * as Utils from 'utils/utils.jsx';
import Constants from 'utils/constants.jsx'; import Constants from 'utils/constants.jsx';
const ActionTypes = Constants.ActionTypes;
import {FormattedMessage, FormattedDate} from 'react-intl'; import {FormattedMessage, FormattedDate} from 'react-intl';
import React from 'react'; import React from 'react';
import {Link} from 'react-router'; import {browserHistory} from 'react-router';
export default class SearchResultsItem extends React.Component { export default class SearchResultsItem extends React.Component {
constructor(props) { constructor(props) {
@@ -105,15 +107,37 @@ export default class SearchResultsItem extends React.Component {
</time> </time>
</li> </li>
<li> <li>
<Link <a
to={'/' + window.location.pathname.split('/')[1] + '/pl/' + post.id} 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' className='search-item__jump'
> >
<FormattedMessage <FormattedMessage
id='search_item.jump' id='search_item.jump'
defaultMessage='Jump' defaultMessage='Jump'
/> />
</Link> </a>
</li> </li>
<li> <li>
<a <a

Просмотреть файл

@@ -937,7 +937,7 @@ export function isValidUsername(name) {
} }
export function isMobile() { export function isMobile() {
return screen.width <= 768; return window.innerWidth <= 768;
} }
export function isComment(post) { export function isComment(post) {