about summary refs log tree commit diff
path: root/app/assets/javascripts
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-12-24 01:39:14 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-12-24 01:39:14 +0100
commitc3e9ba6a66bfcb9e33edebc73adea0a17d7f02a6 (patch)
tree7b884ea4a61189e35b9f1e232b73a7ef36eae487 /app/assets/javascripts
parent0a84ab43d24bf1973be263ccddca8eabd231f271 (diff)
Fix #357 - Also make textarea blur close suggestions which make it more accessible on touch devices
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/components/components/autosuggest_textarea.jsx7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/assets/javascripts/components/components/autosuggest_textarea.jsx b/app/assets/javascripts/components/components/autosuggest_textarea.jsx
index 95ca5f2f6..8d9da1601 100644
--- a/app/assets/javascripts/components/components/autosuggest_textarea.jsx
+++ b/app/assets/javascripts/components/components/autosuggest_textarea.jsx
@@ -55,7 +55,7 @@ const AutosuggestTextarea = React.createClass({
     if (token != null && this.state.lastToken !== token) {
       this.setState({ lastToken: token, selectedSuggestion: 0, tokenStart });
       this.props.onSuggestionsFetchRequested(token);
-    } else if (token === null && this.state.lastToken != null) {
+    } else if (token === null) {
       this.setState({ lastToken: null });
       this.props.onSuggestionsClearRequested();
     }
@@ -107,6 +107,10 @@ const AutosuggestTextarea = React.createClass({
     }
   },
 
+  onBlur () {
+    this.setState({ suggestionsHidden: true });
+  },
+
   onSuggestionClick (suggestion, e) {
     e.preventDefault();
     this.props.onSuggestionSelected(this.state.tokenStart, this.state.lastToken, suggestion);
@@ -137,6 +141,7 @@ const AutosuggestTextarea = React.createClass({
           onChange={this.onChange}
           onKeyDown={this.onKeyDown}
           onKeyUp={onKeyUp}
+          onBlur={this.onBlur}
         />
 
         <div style={{ display: (suggestions.size > 0 && !suggestionsHidden) ? 'block' : 'none' }} className='autosuggest-textarea__suggestions'>