From e63a32dc105daf49646d0b5ce150e69b6987b5c3 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 2 Aug 2016 11:00:00 +0100 Subject: [PATCH] Fix warnings from MessageComposer Fix a couple of warnings from React about required properties not being set. --- src/components/views/rooms/MessageComposer.js | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/components/views/rooms/MessageComposer.js b/src/components/views/rooms/MessageComposer.js index c27a61c33a..282f7f013f 100644 --- a/src/components/views/rooms/MessageComposer.js +++ b/src/components/views/rooms/MessageComposer.js @@ -37,6 +37,8 @@ export default class MessageComposer extends React.Component { this.onUpArrow = this.onUpArrow.bind(this); this.onDownArrow = this.onDownArrow.bind(this); this.onTab = this.onTab.bind(this); + this._tryComplete = this._tryComplete.bind(this); + this._onAutocompleteConfirm = this._onAutocompleteConfirm.bind(this); this.state = { autocompleteQuery: '', @@ -142,7 +144,22 @@ export default class MessageComposer extends React.Component { } onTab() { - return this.refs.autocomplete.onTab(); + // FIXME Autocomplete doesn't have an onTab - what is this supposed to do? + // return this.refs.autocomplete.onTab(); + return false; + } + + _tryComplete(): boolean { + if (this.refs.autocomplete) { + return this.refs.autocomplete.onConfirm(); + } + return false; + } + + _onAutocompleteConfirm(range, completion) { + if (this.messageComposerInput) { + this.messageComposerInput.onConfirmAutocompletion(range, completion); + } } render() { @@ -203,7 +220,7 @@ export default class MessageComposer extends React.Component { key="controls_input" onResize={this.props.onResize} room={this.props.room} - tryComplete={this.refs.autocomplete && this.refs.autocomplete.onConfirm} + tryComplete={this._tryComplete} onUpArrow={this.onUpArrow} onDownArrow={this.onDownArrow} onTab={this.onTab} @@ -227,7 +244,7 @@ export default class MessageComposer extends React.Component {