From 82407bd44aeac52c526b57c7c3ef5c8579760849 Mon Sep 17 00:00:00 2001 From: George Goldberg Date: Tue, 8 Aug 2017 13:44:12 +0100 Subject: PLT-7313: Show help popover when search focused and empty. (#7134) --- webapp/components/suggestion/suggestion_box.jsx | 30 ++++++++++++++++--------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/webapp/components/suggestion/suggestion_box.jsx b/webapp/components/suggestion/suggestion_box.jsx index 545693cac..2dfd2b5c5 100644 --- a/webapp/components/suggestion/suggestion_box.jsx +++ b/webapp/components/suggestion/suggestion_box.jsx @@ -52,6 +52,11 @@ export default class SuggestionBox extends React.Component { */ completeOnTab: PropTypes.bool, + /** + * Function called when input box gains focus + */ + onFocus: PropTypes.func, + /** * Function called when input box loses focus */ @@ -177,18 +182,21 @@ export default class SuggestionBox extends React.Component { } handleFocus() { - if (!this.props.openOnFocus) { - return; - } - setTimeout(() => { - const textbox = this.getTextbox(); - if (textbox) { - const pretext = textbox.value.substring(0, textbox.selectionEnd); - if (pretext.length >= this.props.requiredCharacters) { - GlobalActions.emitSuggestionPretextChanged(this.suggestionId, pretext); + if (this.props.openOnFocus) { + setTimeout(() => { + const textbox = this.getTextbox(); + if (textbox) { + const pretext = textbox.value.substring(0, textbox.selectionEnd); + if (pretext.length >= this.props.requiredCharacters) { + GlobalActions.emitSuggestionPretextChanged(this.suggestionId, pretext); + } } - } - }); + }); + } + + if (this.props.onFocus) { + this.props.onFocus(); + } } handleChange(e) { -- cgit v1.2.3-1-g7c22