Cleared at mention suggestions when something invalid is typed (#4633)
Этот коммит содержится в:
коммит произвёл
enahum
родитель
84e5425a20
Коммит
a12581cb9e
@@ -4,6 +4,7 @@
|
|||||||
import Suggestion from './suggestion.jsx';
|
import Suggestion from './suggestion.jsx';
|
||||||
|
|
||||||
import ChannelStore from 'stores/channel_store.jsx';
|
import ChannelStore from 'stores/channel_store.jsx';
|
||||||
|
import SuggestionStore from 'stores/suggestion_store.jsx';
|
||||||
|
|
||||||
import {autocompleteUsersInChannel} from 'actions/user_actions.jsx';
|
import {autocompleteUsersInChannel} from 'actions/user_actions.jsx';
|
||||||
|
|
||||||
@@ -106,11 +107,22 @@ export default class AtMentionProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
this.clearTimeout(this.timeoutId);
|
||||||
|
}
|
||||||
|
|
||||||
|
clearTimeout() {
|
||||||
|
if (this.timeoutId) {
|
||||||
clearTimeout(this.timeoutId);
|
clearTimeout(this.timeoutId);
|
||||||
|
this.timeoutId = '';
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePretextChanged(suggestionId, pretext) {
|
handlePretextChanged(suggestionId, pretext) {
|
||||||
clearTimeout(this.timeoutId);
|
const hadSuggestions = this.clearTimeout(this.timeoutId);
|
||||||
|
|
||||||
const captured = (/(?:^|\W)@([a-z0-9\-._]*)$/i).exec(pretext.toLowerCase());
|
const captured = (/(?:^|\W)@([a-z0-9\-._]*)$/i).exec(pretext.toLowerCase());
|
||||||
if (captured) {
|
if (captured) {
|
||||||
@@ -160,5 +172,10 @@ export default class AtMentionProvider {
|
|||||||
Constants.AUTOCOMPLETE_TIMEOUT
|
Constants.AUTOCOMPLETE_TIMEOUT
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hadSuggestions) {
|
||||||
|
// Clear the suggestions since the user has now typed something invalid
|
||||||
|
SuggestionStore.clearSuggestions(suggestionId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user