Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/components/solvers/TextInputMask.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Divider, Text, Textarea } from "@chakra-ui/react";
import Head from "next/head";
import React, { ChangeEvent, ReactElement, useState } from "react";
import React, { ReactElement, useState } from "react";
import { Container } from "../Container";
import { Main } from "../Main";
import { InputButtonPanel } from "./buttons/InputButtonPanel";
Expand All @@ -19,10 +19,10 @@ export const TextInputMask = (props: TextInputMaskProperties) => {
const [text, setText] = useState<string>("");
const [errorString, setErrorString] = useState("");

function onTextAreaChange(event: ChangeEvent<HTMLTextAreaElement>): void {
function onTextChanged(text: string): void {
try {
setText(event.target.value);
props.onTextChanged(event.target.value);
setText(text);
props.onTextChanged(text);

setErrorString('');
} catch (e: any) {
Expand All @@ -46,14 +46,14 @@ export const TextInputMask = (props: TextInputMaskProperties) => {
value={text}
minHeight="10rem"
isInvalid={errorString != ""}
onChange={onTextAreaChange}/>
onChange={x => onTextChanged(x.target.value)}/>

<Text backgroundColor="tomato">{errorString}</Text>

<InputButtonPanel
helpBody={<Help/>}
problemString={text}
setProblemString={setText}
setProblemString={x => onTextChanged(x as string)}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I wasn't sure about is how to handle this properly.
x is a React.SetStateAction<string>, but actually just a string that we can pass to onTextChanged.
I added the part as string to avoid IDE warnings.

uploadString={str => str}
downloadString={str => str}/>

Expand Down