|
1 | | -import _ from 'lodash'; |
2 | 1 | import React, { Component } from 'react'; |
3 | 2 | import PropTypes from 'prop-types'; |
4 | 3 | import Random from 'random-id'; |
@@ -324,7 +323,10 @@ class ChatBot extends Component { |
324 | 323 | this.props.handleEnd({ renderedSteps, steps, values }); |
325 | 324 | } |
326 | 325 | } |
327 | | - |
| 326 | + isInputValueEmpty() { |
| 327 | + const { inputValue } = this.state; |
| 328 | + return Boolean(inputValue) && inputValue.length > 0; |
| 329 | + } |
328 | 330 | isLastPosition(step) { |
329 | 331 | const { renderedSteps } = this.state; |
330 | 332 | const length = renderedSteps.length; |
@@ -371,8 +373,8 @@ class ChatBot extends Component { |
371 | 373 | } |
372 | 374 |
|
373 | 375 | handleSubmitButton() { |
374 | | - const { inputValue, speaking, recognitionEnable } = this.state; |
375 | | - if ((_.isEmpty(inputValue) || speaking) && recognitionEnable) { |
| 376 | + const { speaking, recognitionEnable } = this.state; |
| 377 | + if ((this.isInputValueEmpty() || speaking) && recognitionEnable) { |
376 | 378 | this.recognition.speak(); |
377 | 379 | if (!speaking) { |
378 | 380 | this.setState({ speaking: true }); |
@@ -565,7 +567,7 @@ class ChatBot extends Component { |
565 | 567 | ); |
566 | 568 |
|
567 | 569 | const icon = |
568 | | - (_.isEmpty(inputValue) || speaking) && recognitionEnable ? <MicIcon /> : <SubmitIcon />; |
| 570 | + (this.isInputValueEmpty() || speaking) && recognitionEnable ? <MicIcon /> : <SubmitIcon />; |
569 | 571 |
|
570 | 572 | const inputPlaceholder = speaking |
571 | 573 | ? recognitionPlaceholder |
@@ -603,7 +605,7 @@ class ChatBot extends Component { |
603 | 605 | height={height} |
604 | 606 | hideInput={currentStep.hideInput} |
605 | 607 | > |
606 | | - {_.map(renderedSteps, this.renderStep)} |
| 608 | + {Object.values(renderedSteps).map(this.renderStep)} |
607 | 609 | </Content> |
608 | 610 | <Footer className="rsc-footer" style={footerStyle}> |
609 | 611 | {!currentStep.hideInput && ( |
|
0 commit comments