Merge pull request #98 from matrix-org/message_composer_arrows_keys
Fix history scrolling with multiline input
This commit is contained in:
commit
cc3d27bd4b
1 changed files with 12 additions and 17 deletions
|
@ -209,23 +209,18 @@ module.exports = React.createClass({
|
||||||
this.sentHistory.push(input);
|
this.sentHistory.push(input);
|
||||||
this.onEnter(ev);
|
this.onEnter(ev);
|
||||||
}
|
}
|
||||||
else if (ev.keyCode === KeyCode.UP) {
|
else if (ev.keyCode === KeyCode.UP || ev.keyCode === KeyCode.DOWN) {
|
||||||
var input = this.refs.textarea.value;
|
var oldSelectionStart = this.refs.textarea.selectionStart;
|
||||||
var offset = this.refs.textarea.selectionStart || 0;
|
// Remember the keyCode because React will recycle the synthetic event
|
||||||
if (ev.ctrlKey || !input.substr(0, offset).match(/\n/)) {
|
var keyCode = ev.keyCode;
|
||||||
this.sentHistory.next(1);
|
// set a callback so we can see if the cursor position changes as
|
||||||
ev.preventDefault();
|
// a result of this event. If it doesn't, we cycle history.
|
||||||
this.resizeInput();
|
setTimeout(() => {
|
||||||
}
|
if (this.refs.textarea.selectionStart == oldSelectionStart) {
|
||||||
}
|
this.sentHistory.next(keyCode === KeyCode.UP ? 1 : -1);
|
||||||
else if (ev.keyCode === KeyCode.DOWN) {
|
this.resizeInput();
|
||||||
var input = this.refs.textarea.value;
|
}
|
||||||
var offset = this.refs.textarea.selectionStart || 0;
|
}, 0);
|
||||||
if (ev.ctrlKey || !input.substr(offset).match(/\n/)) {
|
|
||||||
this.sentHistory.next(-1);
|
|
||||||
ev.preventDefault();
|
|
||||||
this.resizeInput();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.props.tabComplete) {
|
if (this.props.tabComplete) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue