PLT-6431 Prevented autocompleting while suggestions are being received (#6328)

Этот коммит содержится в:
Harrison Healey
2017-05-04 14:54:50 -04:00
коммит произвёл Christopher Speller
родитель 72351c8ef8
Коммит 44a8f76d99
7 изменённых файлов: 49 добавлений и 14 удалений

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

@@ -222,6 +222,31 @@ class SuggestionStore extends EventEmitter {
return pretext.endsWith(matchedPretext);
}
setSuggestionsPending(id, pending) {
this.suggestions.get(id).suggestionsPending = pending;
}
areSuggestionsPending(id) {
return this.suggestions.get(id).suggestionsPending;
}
setCompletePending(id, pending) {
this.suggestions.get(id).completePending = pending;
}
isCompletePending(id) {
return this.suggestions.get(id).completePending;
}
completeWord(id, term = '', matchedPretext = '') {
this.emitCompleteWord(id, term || this.getSelection(id), matchedPretext || this.getSelectedMatchedPretext(id));
this.setPretext(id, '');
this.clearSuggestions(id);
this.clearSelection(id);
this.emitSuggestionsChanged(id);
}
handleEventPayload(payload) {
const {type, id, ...other} = payload.action;
@@ -248,9 +273,15 @@ class SuggestionStore extends EventEmitter {
this.clearSuggestions(id);
this.addSuggestions(id, other.terms, other.items, other.component, other.matchedPretext);
this.ensureSelectionExists(id);
this.emitSuggestionsChanged(id);
this.setSuggestionsPending(id, false);
if (this.isCompletePending(id)) {
this.completeWord(id);
} else {
this.emitSuggestionsChanged(id);
}
break;
case ActionTypes.SUGGESTION_CLEAR_SUGGESTIONS:
this.setPretext(id, '');
@@ -267,12 +298,11 @@ class SuggestionStore extends EventEmitter {
this.emitSuggestionsChanged(id);
break;
case ActionTypes.SUGGESTION_COMPLETE_WORD:
this.emitCompleteWord(id, other.term || this.getSelection(id), other.matchedPretext || this.getSelectedMatchedPretext(id));
this.setPretext(id, '');
this.clearSuggestions(id);
this.clearSelection(id);
this.emitSuggestionsChanged(id);
if (this.areSuggestionsPending(id)) {
this.setCompletePending(id, true);
} else {
this.completeWord(id, other.term, other.matchedPretext);
}
break;
}
}