From e87c89be25065ff4d0d020b98c71e1ddec28ae49 Mon Sep 17 00:00:00 2001 From: hmhealey Date: Mon, 30 Nov 2015 15:59:17 -0500 Subject: Fixed SuggestionBox keyboard handlers when there are no suggestions available --- web/react/components/suggestion_box.jsx | 40 ++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'web/react') diff --git a/web/react/components/suggestion_box.jsx b/web/react/components/suggestion_box.jsx index a72e17430..ddfcaf811 100644 --- a/web/react/components/suggestion_box.jsx +++ b/web/react/components/suggestion_box.jsx @@ -109,24 +109,28 @@ export default class SuggestionBox extends React.Component { } handleKeyDown(e) { - if (e.which === KeyCodes.UP) { - AppDispatcher.handleViewAction({ - type: ActionTypes.SUGGESTION_SELECT_PREVIOUS, - id: this.suggestionId - }); - e.preventDefault(); - } else if (e.which === KeyCodes.DOWN) { - AppDispatcher.handleViewAction({ - type: ActionTypes.SUGGESTION_SELECT_NEXT, - id: this.suggestionId - }); - e.preventDefault(); - } else if ((e.which === KeyCodes.SPACE || e.which === KeyCodes.ENTER) && SuggestionStore.hasSuggestions(this.suggestionId)) { - AppDispatcher.handleViewAction({ - type: ActionTypes.SUGGESTION_COMPLETE_WORD, - id: this.suggestionId - }); - e.preventDefault(); + if (SuggestionStore.hasSuggestions(this.suggestionId)) { + if (e.which === KeyCodes.UP) { + AppDispatcher.handleViewAction({ + type: ActionTypes.SUGGESTION_SELECT_PREVIOUS, + id: this.suggestionId + }); + e.preventDefault(); + } else if (e.which === KeyCodes.DOWN) { + AppDispatcher.handleViewAction({ + type: ActionTypes.SUGGESTION_SELECT_NEXT, + id: this.suggestionId + }); + e.preventDefault(); + } else if (e.which === KeyCodes.SPACE || e.which === KeyCodes.ENTER) { + AppDispatcher.handleViewAction({ + type: ActionTypes.SUGGESTION_COMPLETE_WORD, + id: this.suggestionId + }); + e.preventDefault(); + } else if (this.props.onKeyDown) { + this.props.onKeyDown(e); + } } else if (this.props.onKeyDown) { this.props.onKeyDown(e); } -- cgit v1.2.3-1-g7c22