summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Goldberg <george@gberg.me>2017-08-08 13:44:12 +0100
committerJoram Wilander <jwawilander@gmail.com>2017-08-08 08:44:12 -0400
commit82407bd44aeac52c526b57c7c3ef5c8579760849 (patch)
tree141b124081515d7be9dafc1973b09bcb844c9cf1
parentbec6b90b8d8cf2d77b576ef4fb9b7dce3c1e5832 (diff)
downloadchat-82407bd44aeac52c526b57c7c3ef5c8579760849.tar.gz
chat-82407bd44aeac52c526b57c7c3ef5c8579760849.tar.bz2
chat-82407bd44aeac52c526b57c7c3ef5c8579760849.zip
PLT-7313: Show help popover when search focused and empty. (#7134)
-rw-r--r--webapp/components/suggestion/suggestion_box.jsx30
1 files 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
@@ -53,6 +53,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
*/
onBlur: PropTypes.func,
@@ -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) {