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

Этот коммит содержится в:
George Goldberg
2017-08-08 13:44:12 +01:00
коммит произвёл Joram Wilander
родитель bec6b90b8d
Коммит 82407bd44a

Просмотреть файл

@@ -52,6 +52,11 @@ export default class SuggestionBox extends React.Component {
*/ */
completeOnTab: PropTypes.bool, completeOnTab: PropTypes.bool,
/**
* Function called when input box gains focus
*/
onFocus: PropTypes.func,
/** /**
* Function called when input box loses focus * Function called when input box loses focus
*/ */
@@ -177,18 +182,21 @@ export default class SuggestionBox extends React.Component {
} }
handleFocus() { handleFocus() {
if (!this.props.openOnFocus) { if (this.props.openOnFocus) {
return; setTimeout(() => {
} const textbox = this.getTextbox();
setTimeout(() => { if (textbox) {
const textbox = this.getTextbox(); const pretext = textbox.value.substring(0, textbox.selectionEnd);
if (textbox) { if (pretext.length >= this.props.requiredCharacters) {
const pretext = textbox.value.substring(0, textbox.selectionEnd); GlobalActions.emitSuggestionPretextChanged(this.suggestionId, pretext);
if (pretext.length >= this.props.requiredCharacters) { }
GlobalActions.emitSuggestionPretextChanged(this.suggestionId, pretext);
} }
} });
}); }
if (this.props.onFocus) {
this.props.onFocus();
}
} }
handleChange(e) { handleChange(e) {