Fix input history

This commit is contained in:
Ken-Håvard Lieng 2017-05-21 23:23:21 +02:00
parent 4c70d11a86
commit c428842db7
2 changed files with 23 additions and 25 deletions

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ export default class MessageInput extends PureComponent {
const { tab, runCommand, sendMessage, addInputHistory, incrementInputHistory,
decrementInputHistory, resetInputHistory } = this.props;
if (e.which === 13 && e.target.value) {
if (e.key === 'Enter' && e.target.value) {
if (e.target.value[0] === '/') {
runCommand(e.target.value, tab.name, tab.server);
} else if (tab.name) {
@ -19,14 +19,12 @@ export default class MessageInput extends PureComponent {
addInputHistory(e.target.value);
resetInputHistory();
this.setState({ value: '' });
} else if (e.which === 38) {
} else if (e.key === 'ArrowUp') {
e.preventDefault();
incrementInputHistory();
} else if (e.which === 40) {
} else if (e.key === 'ArrowDown') {
decrementInputHistory();
} else if (e.key === 'Backspace' || e.key === 'Delete') {
resetInputHistory();
} else if (e.key === 'Unidentified') {
} else {
this.setState({ value: e.target.value });
resetInputHistory();
}