summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-11-22 12:21:51 -0500
committerenahum <nahumhbl@gmail.com>2016-11-22 14:21:51 -0300
commita12581cb9eba725425dd7222a4986870eacda02e (patch)
tree7b4094abd2dd826418e608f7ce8bb59ae3d583f0
parent84e5425a2003f9cb66fe7f74186ab2d539d5a21c (diff)
downloadchat-a12581cb9eba725425dd7222a4986870eacda02e.tar.gz
chat-a12581cb9eba725425dd7222a4986870eacda02e.tar.bz2
chat-a12581cb9eba725425dd7222a4986870eacda02e.zip
Cleared at mention suggestions when something invalid is typed (#4633)
-rw-r--r--webapp/components/suggestion/at_mention_provider.jsx21
1 files changed, 19 insertions, 2 deletions
diff --git a/webapp/components/suggestion/at_mention_provider.jsx b/webapp/components/suggestion/at_mention_provider.jsx
index 13b9344ad..6118b8d98 100644
--- a/webapp/components/suggestion/at_mention_provider.jsx
+++ b/webapp/components/suggestion/at_mention_provider.jsx
@@ -4,6 +4,7 @@
import Suggestion from './suggestion.jsx';
import ChannelStore from 'stores/channel_store.jsx';
+import SuggestionStore from 'stores/suggestion_store.jsx';
import {autocompleteUsersInChannel} from 'actions/user_actions.jsx';
@@ -106,11 +107,22 @@ export default class AtMentionProvider {
}
componentWillUnmount() {
- clearTimeout(this.timeoutId);
+ this.clearTimeout(this.timeoutId);
+ }
+
+ clearTimeout() {
+ if (this.timeoutId) {
+ clearTimeout(this.timeoutId);
+ this.timeoutId = '';
+
+ return true;
+ }
+
+ return false;
}
handlePretextChanged(suggestionId, pretext) {
- clearTimeout(this.timeoutId);
+ const hadSuggestions = this.clearTimeout(this.timeoutId);
const captured = (/(?:^|\W)@([a-z0-9\-._]*)$/i).exec(pretext.toLowerCase());
if (captured) {
@@ -160,5 +172,10 @@ export default class AtMentionProvider {
Constants.AUTOCOMPLETE_TIMEOUT
);
}
+
+ if (hadSuggestions) {
+ // Clear the suggestions since the user has now typed something invalid
+ SuggestionStore.clearSuggestions(suggestionId);
+ }
}
}