diff options
author | hmhealey <harrisonmhealey@gmail.com> | 2015-12-03 15:13:25 -0500 |
---|---|---|
committer | hmhealey <harrisonmhealey@gmail.com> | 2015-12-03 15:16:39 -0500 |
commit | f103e4c815234fd5f451fe66e29bc17f0b20cadb (patch) | |
tree | 77c699442b6f5e768ebfd5805d08de91af0913a4 /web/react/components/suggestion/suggestion_box.jsx | |
parent | b69cc7a94a9fb69dda259b2286eeefc3d6a2ec95 (diff) | |
download | chat-f103e4c815234fd5f451fe66e29bc17f0b20cadb.tar.gz chat-f103e4c815234fd5f451fe66e29bc17f0b20cadb.tar.bz2 chat-f103e4c815234fd5f451fe66e29bc17f0b20cadb.zip |
Changed SuggestionBox to clear its suggestions on losing focus
Diffstat (limited to 'web/react/components/suggestion/suggestion_box.jsx')
-rw-r--r-- | web/react/components/suggestion/suggestion_box.jsx | 32 |
1 files changed, 3 insertions, 29 deletions
diff --git a/web/react/components/suggestion/suggestion_box.jsx b/web/react/components/suggestion/suggestion_box.jsx index 4ca461e82..4cfb38f8e 100644 --- a/web/react/components/suggestion/suggestion_box.jsx +++ b/web/react/components/suggestion/suggestion_box.jsx @@ -13,7 +13,6 @@ export default class SuggestionBox extends React.Component { super(props); this.handleDocumentClick = this.handleDocumentClick.bind(this); - this.handleFocus = this.handleFocus.bind(this); this.handleChange = this.handleChange.bind(this); this.handleCompleteWord = this.handleCompleteWord.bind(this); @@ -21,10 +20,6 @@ export default class SuggestionBox extends React.Component { this.handlePretextChanged = this.handlePretextChanged.bind(this); this.suggestionId = Utils.generateId(); - - this.state = { - focused: false - }; } componentDidMount() { @@ -49,27 +44,11 @@ export default class SuggestionBox extends React.Component { } handleDocumentClick(e) { - if (!this.state.focused) { - return; - } - const container = $(ReactDOM.findDOMNode(this)); if (!(container.is(e.target) || container.has(e.target).length > 0)) { // we can't just use blur for this because it fires and hides the children before // their click handlers can be called - this.setState({ - focused: false - }); - } - } - - handleFocus() { - this.setState({ - focused: true - }); - - if (this.props.onFocus) { - this.props.onFocus(); + EventHelpers.emitClearSuggestions(this.suggestionId); } } @@ -134,7 +113,6 @@ export default class SuggestionBox extends React.Component { render() { const newProps = Object.assign({}, this.props, { - onFocus: this.handleFocus, onChange: this.handleChange, onKeyDown: this.handleKeyDown }); @@ -162,10 +140,7 @@ export default class SuggestionBox extends React.Component { return ( <div> {textbox} - <SuggestionListComponent - suggestionId={this.suggestionId} - show={this.state.focused} - /> + <SuggestionListComponent suggestionId={this.suggestionId} /> </div> ); } @@ -184,6 +159,5 @@ SuggestionBox.propTypes = { // explicitly name any input event handlers we override and need to manually call onChange: React.PropTypes.func, - onKeyDown: React.PropTypes.func, - onFocus: React.PropTypes.func + onKeyDown: React.PropTypes.func }; |