Fix undefined value case
This commit is contained in:
parent
5787bfcf2f
commit
7390c464ac
1 changed files with 8 additions and 5 deletions
|
@ -90,7 +90,7 @@ export default function TextareaWithSuggestions(props: Props) {
|
|||
placeholder,
|
||||
searchQuery,
|
||||
type,
|
||||
value: messageValue,
|
||||
value: messageValue = '',
|
||||
autoFocus,
|
||||
submitButtonRef,
|
||||
spellCheck,
|
||||
|
@ -274,14 +274,17 @@ export default function TextareaWithSuggestions(props: Props) {
|
|||
if (!suggestionValue) return;
|
||||
|
||||
const elem = inputRef && inputRef.current;
|
||||
// $FlowFixMe
|
||||
const newCursorPos = suggestionValue.beforeTerm.length + suggestionValue.index + selectedValue.length + 1;
|
||||
|
||||
// $FlowFixMe
|
||||
const contentBegin = messageValue.substring(0, suggestionValue.index);
|
||||
// $FlowFixMe
|
||||
const replaceValue = suggestionValue.beforeTerm + selectedValue;
|
||||
const contentEnd =
|
||||
messageValue.length > suggestionValue.lastIndex
|
||||
? messageValue.substring(suggestionValue.lastIndex, messageValue.length)
|
||||
: ' ';
|
||||
// $FlowFixMe
|
||||
const endTo = messageValue.substring(suggestionValue.lastIndex, messageValue.length);
|
||||
// $FlowFixMe
|
||||
const contentEnd = messageValue.length > suggestionValue.lastIndex ? endTo : ' ';
|
||||
|
||||
const newValue = contentBegin + replaceValue + contentEnd;
|
||||
|
||||
|
|
Loading…
Reference in a new issue