Fixed SuggestionBox keyboard handlers when there are no suggestions available

Этот коммит содержится в:
hmhealey
2015-11-30 15:59:17 -05:00
родитель 4845067582
Коммит e87c89be25

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

@@ -109,6 +109,7 @@ export default class SuggestionBox extends React.Component {
} }
handleKeyDown(e) { handleKeyDown(e) {
if (SuggestionStore.hasSuggestions(this.suggestionId)) {
if (e.which === KeyCodes.UP) { if (e.which === KeyCodes.UP) {
AppDispatcher.handleViewAction({ AppDispatcher.handleViewAction({
type: ActionTypes.SUGGESTION_SELECT_PREVIOUS, type: ActionTypes.SUGGESTION_SELECT_PREVIOUS,
@@ -121,7 +122,7 @@ export default class SuggestionBox extends React.Component {
id: this.suggestionId id: this.suggestionId
}); });
e.preventDefault(); e.preventDefault();
} else if ((e.which === KeyCodes.SPACE || e.which === KeyCodes.ENTER) && SuggestionStore.hasSuggestions(this.suggestionId)) { } else if (e.which === KeyCodes.SPACE || e.which === KeyCodes.ENTER) {
AppDispatcher.handleViewAction({ AppDispatcher.handleViewAction({
type: ActionTypes.SUGGESTION_COMPLETE_WORD, type: ActionTypes.SUGGESTION_COMPLETE_WORD,
id: this.suggestionId id: this.suggestionId
@@ -130,6 +131,9 @@ export default class SuggestionBox extends React.Component {
} else if (this.props.onKeyDown) { } else if (this.props.onKeyDown) {
this.props.onKeyDown(e); this.props.onKeyDown(e);
} }
} else if (this.props.onKeyDown) {
this.props.onKeyDown(e);
}
} }
handlePretextChanged(pretext) { handlePretextChanged(pretext) {