summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-11-13 13:43:44 -0500
committerhmhealey <harrisonmhealey@gmail.com>2015-11-13 13:43:44 -0500
commitc31e811351f849ae263fa864e8b799ac98ac456b (patch)
tree12073cfaeda6341cd1649fb55092e113f10f01f9 /web
parentc5c96082c5b076d4776e18503d9317cdaeb6066c (diff)
downloadchat-c31e811351f849ae263fa864e8b799ac98ac456b.tar.gz
chat-c31e811351f849ae263fa864e8b799ac98ac456b.tar.bz2
chat-c31e811351f849ae263fa864e8b799ac98ac456b.zip
Fixed some console errors with the search autocomplete when there are no suggestions to show
Diffstat (limited to 'web')
-rw-r--r--web/react/components/search_autocomplete.jsx12
1 files changed, 7 insertions, 5 deletions
diff --git a/web/react/components/search_autocomplete.jsx b/web/react/components/search_autocomplete.jsx
index d245c6bac..04384203f 100644
--- a/web/react/components/search_autocomplete.jsx
+++ b/web/react/components/search_autocomplete.jsx
@@ -46,7 +46,7 @@ export default class SearchAutocomplete extends React.Component {
componentDidUpdate(prevProps, prevState) {
const content = $(ReactDOM.findDOMNode(this.refs.searchPopover)).find('.popover-content');
- if (this.state.show) {
+ if (this.state.show && this.state.suggestions.length > 0) {
if (!prevState.show) {
content.perfectScrollbar();
content.css('max-height', $(window).height() - 200);
@@ -143,10 +143,12 @@ export default class SearchAutocomplete extends React.Component {
}
getSelection() {
- if (this.state.mode === 'channels') {
- return this.state.suggestions[this.state.selection].name;
- } else if (this.state.mode === 'users') {
- return this.state.suggestions[this.state.selection].username;
+ if (this.state.suggestions.length > 0) {
+ if (this.state.mode === 'channels') {
+ return this.state.suggestions[this.state.selection].name;
+ } else if (this.state.mode === 'users') {
+ return this.state.suggestions[this.state.selection].username;
+ }
}
return '';