Skip to content

Commit 836dea8

Browse files
committed
1 parent 8d0ac48 commit 836dea8

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

example/components/Example.jsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,24 @@ const steps = [
1818
{
1919
id: '1',
2020
message: 'Hello World',
21+
trigger: '2',
22+
},
23+
{
24+
id: '2',
25+
user: true,
26+
trigger: '3',
27+
},
28+
{
29+
id: '3',
30+
message: 'Hello World',
2131
end: true,
2232
},
2333
];
2434

2535

2636
const ThemedExample = () => (
2737
<ThemeProvider theme={otherFontTheme}>
28-
<ChatBot steps={steps} />
38+
<ChatBot recognitionEnable steps={steps} />
2939
</ThemeProvider>
3040
);
3141

lib/ChatBot.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ class ChatBot extends Component {
386386

387387
isInputValueEmpty = () => {
388388
const { inputValue } = this.state;
389-
return Boolean(inputValue) && inputValue.length > 0;
389+
return !inputValue || inputValue.length === 0;
390390
}
391391

392392
isLastPosition = (step) => {
@@ -436,13 +436,15 @@ class ChatBot extends Component {
436436

437437
handleSubmitButton = () => {
438438
const { speaking, recognitionEnable } = this.state;
439+
439440
if ((this.isInputValueEmpty() || speaking) && recognitionEnable) {
440441
this.recognition.speak();
441442
if (!speaking) {
442443
this.setState({ speaking: true });
443444
}
444445
return;
445446
}
447+
446448
this.submitUserMessage();
447449
}
448450

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)