From 7300a41678464fceb551b1419ac218aed5e1f828 Mon Sep 17 00:00:00 2001 From: Sorin Davidoi Date: Wed, 7 Jun 2017 20:05:53 +0200 Subject: [PATCH] fix(components/autosuggest_textarea): Race condition regarding onBlur (#3631) --- .../mastodon/components/autosuggest_textarea.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/app/javascript/mastodon/components/autosuggest_textarea.js b/app/javascript/mastodon/components/autosuggest_textarea.js index 5bfc200a5b..9a5760a2cf 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} >