Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #384 from aviraldg/fix-composer-up-down
Browse files Browse the repository at this point in the history
fix: allow up/down normally for no completions
  • Loading branch information
dbkr committed Aug 3, 2016
2 parents 1ff2ce6 + a2d64f5 commit efdcc6d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 6 additions & 0 deletions src/components/views/rooms/Autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
12 changes: 4 additions & 8 deletions src/components/views/rooms/MessageComposerInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,18 +497,14 @@ export default class MessageComposerInput extends React.Component {
}

onUpArrow(e) {
if(this.props.onUpArrow) {
if(this.props.onUpArrow()) {
e.preventDefault();
}
if (this.props.onUpArrow && this.props.onUpArrow()) {
e.preventDefault();
}
}

onDownArrow(e) {
if(this.props.onDownArrow) {
if(this.props.onDownArrow()) {
e.preventDefault();
}
if (this.props.onDownArrow && this.props.onDownArrow()) {
e.preventDefault();
}
}

Expand Down

0 comments on commit efdcc6d

Please sign in to comment.