about summary refs log tree commit diff
path: root/app/javascript
diff options
context:
space:
mode:
authorSorin Davidoi <sorin.davidoi@gmail.com>2017-06-07 20:05:53 +0200
committerEugen Rochko <eugen@zeonfederated.com>2017-06-07 20:05:53 +0200
commit8cf8ce4ac0c2fb8b9d820cbea018dbfeba48ceec (patch)
tree2091f91e6f5d3c5511046610201e9ea5680eed82 /app/javascript
parent0f1b1d78b15bd779c3427d4275d45d3e34e0b2ef (diff)
fix(components/autosuggest_textarea): Race condition regarding onBlur (#3631)
Diffstat (limited to 'app/javascript')
-rw-r--r--app/javascript/mastodon/components/autosuggest_textarea.js10
1 files changed, 2 insertions, 8 deletions
diff --git a/app/javascript/mastodon/components/autosuggest_textarea.js b/app/javascript/mastodon/components/autosuggest_textarea.js
index 5bfc200a5..9a5760a2c 100644
--- a/app/javascript/mastodon/components/autosuggest_textarea.js
+++ b/app/javascript/mastodon/components/autosuggest_textarea.js
@@ -124,13 +124,7 @@ class AutosuggestTextarea extends ImmutablePureComponent {
   }
 
   onBlur = () => {
-    // If we hide the suggestions immediately, then this will prevent the
-    // onClick for the suggestions themselves from firing.
-    // Setting a short window for that to take place before hiding the
-    // suggestions ensures that can't happen.
-    setTimeout(() => {
-      this.setState({ suggestionsHidden: true });
-    }, 100);
+    this.setState({ suggestionsHidden: true });
   }
 
   onSuggestionClick = (e) => {
@@ -191,7 +185,7 @@ class AutosuggestTextarea extends ImmutablePureComponent {
               key={suggestion}
               data-index={suggestion}
               className={`autosuggest-textarea__suggestions__item ${i === selectedSuggestion ? 'selected' : ''}`}
-              onClick={this.onSuggestionClick}
+              onMouseDown={this.onSuggestionClick}
             >
               <AutosuggestAccountContainer id={suggestion} />
             </div>