Skip to content

Commit c1b9ae4

Browse files
Merge pull request LucasBassetti#173 from Spenhouet/bugfix/160
Show input by default for user step
2 parents f7f8517 + 92d4961 commit c1b9ae4

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

lib/ChatBot.jsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class ChatBot extends Component {
6464
const chatSteps = {};
6565

6666
const defaultBotSettings = { delay: botDelay, avatar: botAvatar };
67-
const defaultUserSettings = { delay: userDelay, avatar: userAvatar };
67+
const defaultUserSettings = { delay: userDelay, avatar: userAvatar, hideInput: false };
6868
const defaultCustomSettings = { delay: customDelay };
6969

7070
for (let i = 0, len = steps.length; i < len; i += 1) {
@@ -108,7 +108,9 @@ class ChatBot extends Component {
108108
// focus input if last step cached is a user step
109109
this.setState({ disabled: false }, () => {
110110
if (enableMobileAutoFocus || !isMobile()) {
111-
this.input.focus();
111+
if (this.input) {
112+
this.input.focus();
113+
}
112114
}
113115
});
114116
},
@@ -297,7 +299,9 @@ class ChatBot extends Component {
297299
if (nextStep.user) {
298300
this.setState({ disabled: false }, () => {
299301
if (enableMobileAutoFocus || !isMobile()) {
300-
this.input.focus();
302+
if (this.input) {
303+
this.input.focus();
304+
}
301305
}
302306
});
303307
} else {
@@ -461,7 +465,9 @@ class ChatBot extends Component {
461465
inputValue: '',
462466
},
463467
() => {
464-
this.input.blur();
468+
if (this.input) {
469+
this.input.blur();
470+
}
465471
},
466472
);
467473
}
@@ -490,7 +496,9 @@ class ChatBot extends Component {
490496
},
491497
() => {
492498
if (enableMobileAutoFocus || !isMobile()) {
493-
this.input.focus();
499+
if (this.input) {
500+
this.input.focus();
501+
}
494502
}
495503
},
496504
);

0 commit comments

Comments
 (0)