gearheads
/
mastodon
Archived
2
0
Fork 0

Textarea: fix clicking on name suggestions

This was broken in c3e9ba6a, which added an onBlur to hide the
suggestions when the textarea loses focus. Unfortunately, this fired
even when the textarea lost focus to its own suggestions box, and that
meant that onSuggestionClick is never called.

Setting a short window in which onSuggestionClick can still happen
before hiding the suggestion area ensures that clicking still works,
while still hiding the suggestions if the user clicks on something else.
gh/stable
Misty De Meo 2017-01-22 22:57:58 -08:00
parent 1953e3b6ed
commit 33fd8a7d95
1 changed files with 8 additions and 1 deletions

View File

@ -118,12 +118,19 @@ const AutosuggestTextarea = React.createClass({
}, },
onBlur () { onBlur () {
this.setState({ suggestionsHidden: true }); // 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);
}, },
onSuggestionClick (suggestion, e) { onSuggestionClick (suggestion, e) {
e.preventDefault(); e.preventDefault();
this.props.onSuggestionSelected(this.state.tokenStart, this.state.lastToken, suggestion); this.props.onSuggestionSelected(this.state.tokenStart, this.state.lastToken, suggestion);
this.textarea.focus();
}, },
componentWillReceiveProps (nextProps) { componentWillReceiveProps (nextProps) {