diff --git a/src/components/views/rooms/Autocomplete.js b/src/components/views/rooms/Autocomplete.js index cdd57801a5..7706cc7ebd 100644 --- a/src/components/views/rooms/Autocomplete.js +++ b/src/components/views/rooms/Autocomplete.js @@ -143,7 +143,6 @@ export default class Autocomplete extends React.Component { return null; } this.setSelection(selectionOffset); - return selectionOffset === COMPOSER_SELECTED ? null : this.state.completionList[selectionOffset - 1]; } // called from MessageComposerInput @@ -155,7 +154,6 @@ export default class Autocomplete extends React.Component { return null; } this.setSelection(selectionOffset); - return selectionOffset === COMPOSER_SELECTED ? null : this.state.completionList[selectionOffset - 1]; } onEscape(e): boolean { @@ -201,6 +199,9 @@ export default class Autocomplete extends React.Component { setSelection(selectionOffset: number) { this.setState({selectionOffset, hide: false}); + if (this.props.onSelectionChange) { + this.props.onSelectionChange(this.state.completionList[selectionOffset - 1]); + } } componentDidUpdate() { diff --git a/src/components/views/rooms/MessageComposerInput.js b/src/components/views/rooms/MessageComposerInput.js index 6d6cc0f3f4..37602a94ca 100644 --- a/src/components/views/rooms/MessageComposerInput.js +++ b/src/components/views/rooms/MessageComposerInput.js @@ -949,8 +949,7 @@ export default class MessageComposerInput extends React.Component { }; moveAutocompleteSelection = (up) => { - const completion = up ? this.autocomplete.onUpArrow() : this.autocomplete.onDownArrow(); - return this.setDisplayedCompletion(completion); + up ? this.autocomplete.onUpArrow() : this.autocomplete.onDownArrow(); }; onEscape = async (e) => { @@ -1133,6 +1132,7 @@ export default class MessageComposerInput extends React.Component { this.autocomplete = e} onConfirm={this.setDisplayedCompletion} + onSelectionChange={this.setDisplayedCompletion} query={this.getAutocompleteQuery(content)} selection={selection}/>