1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-11-08 21:42:24 +03:00

Merge pull request #384 from aviraldg/fix-composer-up-down

fix: allow up/down normally for no completions
This commit is contained in:
David Baker
2016-08-03 13:55:13 +01:00
committed by GitHub
2 changed files with 10 additions and 8 deletions

View File

@@ -64,6 +64,9 @@ export default class Autocomplete extends React.Component {
onUpArrow(): boolean {
let completionCount = this.countCompletions(),
selectionOffset = (completionCount + this.state.selectionOffset - 1) % completionCount;
if (!completionCount) {
return false;
}
this.setSelection(selectionOffset);
return true;
}
@@ -72,6 +75,9 @@ export default class Autocomplete extends React.Component {
onDownArrow(): boolean {
let completionCount = this.countCompletions(),
selectionOffset = (this.state.selectionOffset + 1) % completionCount;
if (!completionCount) {
return false;
}
this.setSelection(selectionOffset);
return true;
}

View File

@@ -497,20 +497,16 @@ export default class MessageComposerInput extends React.Component {
}
onUpArrow(e) {
if(this.props.onUpArrow) {
if(this.props.onUpArrow()) {
if (this.props.onUpArrow && this.props.onUpArrow()) {
e.preventDefault();
}
}
}
onDownArrow(e) {
if(this.props.onDownArrow) {
if(this.props.onDownArrow()) {
if (this.props.onDownArrow && this.props.onDownArrow()) {
e.preventDefault();
}
}
}
onTab(e) {
if (this.props.tryComplete) {