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

Commit

Permalink
Fix click-to-complete in RTE
Browse files Browse the repository at this point in the history
  • Loading branch information
aviraldg committed Sep 21, 2016
1 parent 4421742 commit f171985
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions src/components/views/rooms/Autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export default class Autocomplete extends React.Component {
super(props);

this.completionPromise = null;
this.onConfirm = this.onConfirm.bind(this);
this.hide = this.hide.bind(this);
this.onCompletionClicked = this.onCompletionClicked.bind(this);

this.state = {
// list of completionResults, each containing completions
Expand Down Expand Up @@ -157,16 +157,13 @@ export default class Autocomplete extends React.Component {
return done.promise;
}

/** called from MessageComposerInput
* @returns {boolean} whether confirmation was handled
*/
onConfirm(): boolean {
onCompletionClicked(): boolean {
if (this.countCompletions() === 0 || this.state.selectionOffset === COMPOSER_SELECTED) {
return false;
}

let selectedCompletion = this.state.completionList[this.state.selectionOffset - 1];
this.props.onConfirm(selectedCompletion.range, selectedCompletion.completion);
this.props.onConfirm(this.state.completionList[this.state.selectionOffset - 1]);
this.hide();

return true;
}
Expand Down Expand Up @@ -204,7 +201,7 @@ export default class Autocomplete extends React.Component {
let onMouseOver = () => this.setSelection(componentPosition);
let onClick = () => {
this.setSelection(componentPosition);
this.onConfirm();
this.onCompletionClicked();
};

return React.cloneElement(completion.component, {
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/rooms/MessageComposer.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export default class MessageComposer extends React.Component {

_tryComplete(): boolean {
if (this.refs.autocomplete) {
return this.refs.autocomplete.onConfirm();
return this.refs.autocomplete.onCompletionClicked();
}
return false;
}
Expand Down

0 comments on commit f171985

Please sign in to comment.