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