PLT-7313: Show help popover when search focused and empty. (#7134)

This commit is contained in:
George Goldberg
2017-08-08 13:44:12 +01:00
committed by Joram Wilander
parent bec6b90b8d
commit 82407bd44a

View File

@@ -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) {