From 4845067582fdb9092413207f93eff36e0711354a Mon Sep 17 00:00:00 2001 From: hmhealey Date: Fri, 27 Nov 2015 10:38:35 -0500 Subject: Fixed losing suggestion selection when entering additional characters --- web/react/stores/suggestion_store.jsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'web/react/stores/suggestion_store.jsx') diff --git a/web/react/stores/suggestion_store.jsx b/web/react/stores/suggestion_store.jsx index 016929501..8e64d02a3 100644 --- a/web/react/stores/suggestion_store.jsx +++ b/web/react/stores/suggestion_store.jsx @@ -93,6 +93,11 @@ class SuggestionStore extends EventEmitter { suggestion.terms = []; suggestion.items = []; suggestion.components = []; + } + + clearSelection(id) { + const suggestion = this.suggestions.get(id); + suggestion.selection = ''; } @@ -237,10 +242,11 @@ class SuggestionStore extends EventEmitter { this.setPretext(id, ''); this.clearSuggestions(id); + this.clearSelection(id); this.emitSuggestionsChanged(id); break; } } } -export default new SuggestionStore(); \ No newline at end of file +export default new SuggestionStore(); -- cgit v1.2.3-1-g7c22 From 0c449ba5c98b4200ac255e2e6b70b754452a861e Mon Sep 17 00:00:00 2001 From: hmhealey Date: Tue, 1 Dec 2015 10:54:53 -0500 Subject: Replaced CommandList with the new suggestion components --- web/react/stores/suggestion_store.jsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'web/react/stores/suggestion_store.jsx') diff --git a/web/react/stores/suggestion_store.jsx b/web/react/stores/suggestion_store.jsx index 8e64d02a3..5bd13b02d 100644 --- a/web/react/stores/suggestion_store.jsx +++ b/web/react/stores/suggestion_store.jsx @@ -223,11 +223,13 @@ class SuggestionStore extends EventEmitter { this.emitSuggestionsChanged(id); break; case ActionTypes.SUGGESTION_RECEIVED_SUGGESTIONS: - this.setMatchedPretext(id, other.matchedPretext); - this.addSuggestions(id, other.terms, other.items, other.componentType); + if (other.matchedPretext === this.getMatchedPretext(id)) { + // ensure the matched pretext hasn't changed so that we don't receive suggestions for outdated pretext + this.addSuggestions(id, other.terms, other.items, other.component); - this.ensureSelectionExists(id); - this.emitSuggestionsChanged(id); + this.ensureSelectionExists(id); + this.emitSuggestionsChanged(id); + } break; case ActionTypes.SUGGESTION_SELECT_NEXT: this.selectNext(id); -- cgit v1.2.3-1-g7c22 From 101c74d8b82efb43ade6d67f669d586efc9b943c Mon Sep 17 00:00:00 2001 From: hmhealey Date: Wed, 2 Dec 2015 09:31:12 -0500 Subject: Changed Command autocomplete to pick a suggestion when space is pressed --- web/react/stores/suggestion_store.jsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'web/react/stores/suggestion_store.jsx') diff --git a/web/react/stores/suggestion_store.jsx b/web/react/stores/suggestion_store.jsx index 5bd13b02d..182f5810f 100644 --- a/web/react/stores/suggestion_store.jsx +++ b/web/react/stores/suggestion_store.jsx @@ -38,6 +38,7 @@ class SuggestionStore extends EventEmitter { // items: a list of objects backing the terms which may be used in rendering // components: a list of react components that can be used to render their corresponding item // selection: the term currently selected by the keyboard + // completeOnSpace: whether or not space will trigger the term to be autocompleted this.suggestions = new Map(); } @@ -78,7 +79,8 @@ class SuggestionStore extends EventEmitter { terms: [], items: [], components: [], - selection: '' + selection: '', + completeOnSpace: true }); } @@ -93,6 +95,7 @@ class SuggestionStore extends EventEmitter { suggestion.terms = []; suggestion.items = []; suggestion.components = []; + suggestion.completeOnSpace = true; } clearSelection(id) { @@ -117,6 +120,12 @@ class SuggestionStore extends EventEmitter { suggestion.matchedPretext = matchedPretext; } + setCompleteOnSpace(id, completeOnSpace) { + const suggestion = this.suggestions.get(id); + + suggestion.completeOnSpace = completeOnSpace; + } + addSuggestion(id, term, item, component) { const suggestion = this.suggestions.get(id); @@ -180,6 +189,10 @@ class SuggestionStore extends EventEmitter { return this.suggestions.get(id).selection; } + shouldCompleteOnSpace(id) { + return this.suggestions.get(id).completeOnSpace; + } + selectNext(id) { this.setSelectionByDelta(id, 1); } -- cgit v1.2.3-1-g7c22