diff options
author | Joram Wilander <jwawilander@gmail.com> | 2015-11-14 11:48:30 -0500 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2015-11-14 11:48:30 -0500 |
commit | 11f0054bba6a6986967ee3a0ffb6f17fad107783 (patch) | |
tree | 259fc93439d5a79e7e1da4475a984a488d67ead6 /web/react/components/search_autocomplete.jsx | |
parent | f0b1adf6cfaf0f2825b514d2c5e132ebf583652b (diff) | |
parent | c31e811351f849ae263fa864e8b799ac98ac456b (diff) | |
download | chat-11f0054bba6a6986967ee3a0ffb6f17fad107783.tar.gz chat-11f0054bba6a6986967ee3a0ffb6f17fad107783.tar.bz2 chat-11f0054bba6a6986967ee3a0ffb6f17fad107783.zip |
Merge pull request #1431 from hmhealey/plt1149
PLT-1149 Fixed some console errors related to the search autocomplete
Diffstat (limited to 'web/react/components/search_autocomplete.jsx')
-rw-r--r-- | web/react/components/search_autocomplete.jsx | 12 |
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 ''; |