Skip to content

Commit

Permalink
Merge af672df into 187aff9
Browse files Browse the repository at this point in the history
  • Loading branch information
andreistanciu24 committed Feb 1, 2017
2 parents 187aff9 + af672df commit 18aae1f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion webapp/components/rhs_thread.jsx
Expand Up @@ -335,7 +335,7 @@ export default class RhsThread extends React.Component {
var currentId = UserStore.getCurrentId();
var searchForm;
if (currentId != null) {
searchForm = <SearchBox/>;
searchForm = <SearchBox isCommentsPage='true'/>;
}

let profile;
Expand Down
41 changes: 28 additions & 13 deletions webapp/components/search_bar.jsx
Expand Up @@ -37,6 +37,7 @@ export default class SearchBar extends React.Component {

const state = this.getSearchTermStateFromStores();
state.focused = false;
state.isPristine = true;
this.state = state;

this.suggestionProviders = [new SearchChannelProvider(), new SearchUserProvider()];
Expand Down Expand Up @@ -114,7 +115,10 @@ export default class SearchBar extends React.Component {

performSearch(terms, isMentionSearch) {
if (terms.length) {
this.setState({isSearching: true});
this.setState({
isSearching: true,
isPristine: false
});

performSearch(
terms,
Expand Down Expand Up @@ -160,6 +164,25 @@ export default class SearchBar extends React.Component {
}
}

renderHintPopover(helpClass) {
if (!this.props.isCommentsPage && Utils.isMobile() && this.state.isPristine) {
return false;
}

return (
<Popover
id='searchbar-help-popup'
placement='bottom'
className={helpClass}
>
<FormattedHTMLMessage
id='search_bar.usage'
defaultMessage='<h4>Search Options</h4><ul><li><span>Use </span><b>"quotation marks"</b><span> to search for phrases</span></li><li><span>Use </span><b>from:</b><span> to find posts from specific users and </span><b>in:</b><span> to find posts in specific channels</span></li></ul>'
/>
</Popover>
);
}

render() {
const flagIcon = Constants.FLAG_ICON_SVG;
var isSearching = null;
Expand Down Expand Up @@ -279,16 +302,7 @@ export default class SearchBar extends React.Component {
type='search'
/>
{isSearching}
<Popover
id='searchbar-help-popup'
placement='bottom'
className={helpClass}
>
<FormattedHTMLMessage
id='search_bar.usage'
defaultMessage='<h4>Search Options</h4><ul><li><span>Use </span><b>"quotation marks"</b><span> to search for phrases</span></li><li><span>Use </span><b>from:</b><span> to find posts from specific users and </span><b>in:</b><span> to find posts in specific channels</span></li></ul>'
/>
</Popover>
{this.renderHintPopover(helpClass)}
</form>

{mentionBtn}
Expand All @@ -303,5 +317,6 @@ SearchBar.defaultProps = {
};

SearchBar.propTypes = {
showMentionFlagBtns: React.PropTypes.bool
};
showMentionFlagBtns: React.PropTypes.bool,
isCommentsPage: React.PropTypes.bool
};

0 comments on commit 18aae1f

Please sign in to comment.