Skip to content

Commit 1442519

Browse files
committed
fixed issues with initial text input
1 parent 7793349 commit 1442519

3 files changed

Lines changed: 124 additions & 93 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"react-dom": "16.8.0-alpha.1",
4343
"react-monaco-editor": "^0.26.2",
4444
"react-scripts": "2.1.3",
45-
"react-select": "^2.4.3",
45+
"react-select": "^3.0.8",
4646
"react-syntax-highlighter": "^10.3.0",
4747
"spelling": "^2.0.1"
4848
}

src/components/EditableDocument/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @flow
22

33
import React, { useState } from "react"
4-
import CreatableSelect from "react-select/lib/AsyncCreatable"
4+
import CreatableSelect from "react-select/async-creatable"
55
import Spelling from "spelling"
66
import enDictionary from "spelling/dictionaries/en_US"
77
import 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

Comments
 (0)