diff options
author | hmhealey <harrisonmhealey@gmail.com> | 2015-11-30 15:59:17 -0500 |
---|---|---|
committer | hmhealey <harrisonmhealey@gmail.com> | 2015-12-01 16:27:21 -0500 |
commit | e87c89be25065ff4d0d020b98c71e1ddec28ae49 (patch) | |
tree | a1cbe0244019e9bec632aae67405ae492f0133e3 /web/react/components/suggestion_box.jsx | |
parent | 4845067582fdb9092413207f93eff36e0711354a (diff) | |
download | chat-e87c89be25065ff4d0d020b98c71e1ddec28ae49.tar.gz chat-e87c89be25065ff4d0d020b98c71e1ddec28ae49.tar.bz2 chat-e87c89be25065ff4d0d020b98c71e1ddec28ae49.zip |
Fixed SuggestionBox keyboard handlers when there are no suggestions available
Diffstat (limited to 'web/react/components/suggestion_box.jsx')
-rw-r--r-- | web/react/components/suggestion_box.jsx | 40 |
1 files changed, 22 insertions, 18 deletions
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); } |