1
0
mirror of https://github.com/whippyshou/mastodon synced 2024-11-25 07:37:08 +09:00

fix(components/autosuggest_textarea): Race condition regarding onBlur (#3631)

This commit is contained in:
Sorin Davidoi 2017-06-07 20:05:53 +02:00 committed by Eugen Rochko
parent 0f1b1d78b1
commit 8cf8ce4ac0

View File

@ -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>