mirror of https://github.com/vector-im/riot-web
parent
44217422d0
commit
f171985e4c
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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, {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue