You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-08-04 23:02:14 +03:00
@@ -17,8 +17,8 @@ export default class Autocomplete extends React.Component {
|
|||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.completionPromise = null;
|
this.completionPromise = null;
|
||||||
this.onConfirm = this.onConfirm.bind(this);
|
|
||||||
this.hide = this.hide.bind(this);
|
this.hide = this.hide.bind(this);
|
||||||
|
this.onCompletionClicked = this.onCompletionClicked.bind(this);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
// list of completionResults, each containing completions
|
// list of completionResults, each containing completions
|
||||||
@@ -157,16 +157,13 @@ export default class Autocomplete extends React.Component {
|
|||||||
return done.promise;
|
return done.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** called from MessageComposerInput
|
onCompletionClicked(): boolean {
|
||||||
* @returns {boolean} whether confirmation was handled
|
|
||||||
*/
|
|
||||||
onConfirm(): boolean {
|
|
||||||
if (this.countCompletions() === 0 || this.state.selectionOffset === COMPOSER_SELECTED) {
|
if (this.countCompletions() === 0 || this.state.selectionOffset === COMPOSER_SELECTED) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let selectedCompletion = this.state.completionList[this.state.selectionOffset - 1];
|
this.props.onConfirm(this.state.completionList[this.state.selectionOffset - 1]);
|
||||||
this.props.onConfirm(selectedCompletion.range, selectedCompletion.completion);
|
this.hide();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -204,7 +201,7 @@ export default class Autocomplete extends React.Component {
|
|||||||
let onMouseOver = () => this.setSelection(componentPosition);
|
let onMouseOver = () => this.setSelection(componentPosition);
|
||||||
let onClick = () => {
|
let onClick = () => {
|
||||||
this.setSelection(componentPosition);
|
this.setSelection(componentPosition);
|
||||||
this.onConfirm();
|
this.onCompletionClicked();
|
||||||
};
|
};
|
||||||
|
|
||||||
return React.cloneElement(completion.component, {
|
return React.cloneElement(completion.component, {
|
||||||
|
@@ -178,7 +178,7 @@ export default class MessageComposer extends React.Component {
|
|||||||
|
|
||||||
_tryComplete(): boolean {
|
_tryComplete(): boolean {
|
||||||
if (this.refs.autocomplete) {
|
if (this.refs.autocomplete) {
|
||||||
return this.refs.autocomplete.onConfirm();
|
return this.refs.autocomplete.onCompletionClicked();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user