Merge pull request #489 from aviraldg/fix-2128
Force-hide autocomplete after sending message.pull/21833/head
commit
898fbcee30
|
@ -17,7 +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.onCompletionClicked = this.onCompletionClicked.bind(this);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
// list of completionResults, each containing completions
|
// list of completionResults, each containing completions
|
||||||
|
@ -137,6 +138,10 @@ export default class Autocomplete extends React.Component {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
// selectionOffset = 0, so we don't end up completing when autocomplete is hidden
|
// selectionOffset = 0, so we don't end up completing when autocomplete is hidden
|
||||||
|
this.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
hide() {
|
||||||
this.setState({hide: true, selectionOffset: 0});
|
this.setState({hide: true, selectionOffset: 0});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,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;
|
||||||
}
|
}
|
||||||
|
@ -199,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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -567,6 +567,8 @@ export default class MessageComposerInput extends React.Component {
|
||||||
editorState: this.createEditorState(),
|
editorState: this.createEditorState(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.autocomplete.hide();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue