PLT-4600 Properly clear autocomplete suggestions when suggestions are out of date (#4529)

* PLT-4600 Better clear autocomplete suggestions when suggestions are out of date

* Fixed react warnings and removed an eslint ignore
Этот коммит содержится в:
Harrison Healey
2016-11-10 17:00:14 -05:00
коммит произвёл GitHub
родитель 2fdb33042a
Коммит 03e3ac60c2
2 изменённых файлов: 16 добавлений и 5 удалений

Просмотреть файл

@@ -121,6 +121,11 @@ class SuggestionStore extends EventEmitter {
}
addSuggestions(id, terms, items, component, matchedPretext) {
if (this.getPretext(id) !== matchedPretext) {
// These suggestions are out of date since the pretext has changed
return;
}
const suggestion = this.suggestions.get(id);
suggestion.terms.push(...terms);
@@ -218,7 +223,7 @@ class SuggestionStore extends EventEmitter {
}
handleEventPayload(payload) {
const {type, id, ...other} = payload.action; // eslint-disable-line no-use-before-define
const {type, id, ...other} = payload.action;
switch (type) {
case ActionTypes.SUGGESTION_PRETEXT_CHANGED:
@@ -243,6 +248,7 @@ class SuggestionStore extends EventEmitter {
this.emitSuggestionsChanged(id);
break;
case ActionTypes.SUGGESTION_CLEAR_SUGGESTIONS:
this.setPretext(id, '');
this.clearSuggestions(id);
this.clearSelection(id);
this.emitSuggestionsChanged(id);