11// @flow
22
33import React , { useState } from "react"
4- import CreatableSelect from "react-select/lib/AsyncCreatable "
4+ import CreatableSelect from "react-select/async-creatable "
55import Spelling from "spelling"
66import enDictionary from "spelling/dictionaries/en_US"
77import chroma from "chroma-js"
@@ -79,7 +79,8 @@ export default function EditableDocument({
7979 initialText ?: string ,
8080 validator ?: string => Array < string > ,
8181 onChange : string => any ,
82- phraseBank ?: Array < string >
82+ phraseBank ?: Array < string > ,
83+ lowerCaseMode ?: boolean
8384} ) {
8485 const [ inputValue , changeInputValue ] = useState ( )
8586 const [ value , changeValue ] = useState (
@@ -90,6 +91,7 @@ export default function EditableDocument({
9091 const [ validationErrors , changeValidationErrors ] = useState ( [ ] )
9192
9293 const handleChange = v => {
94+ if ( ! v ) v = [ ]
9395 changeValue ( v )
9496 const result = v . map ( l => l . label ) . join ( " " )
9597 try {
@@ -103,7 +105,10 @@ export default function EditableDocument({
103105 const handleKeyDown = ( { key } ) => {
104106 if ( ! inputValue ) return
105107 if ( key === "Enter" || key === "Tab" ) {
106- changeValue ( [ ...value , createOption ( inputValue + " " , yellow [ 700 ] ) ] )
108+ changeValue ( [
109+ ...( value || [ ] ) ,
110+ createOption ( inputValue + " " , yellow [ 700 ] )
111+ ] )
107112 changeInputValue ( "" )
108113 }
109114 }
0 commit comments