From 1030ccd3b7d7b7956bc4c6665db46fee96a70bcd Mon Sep 17 00:00:00 2001 From: ks129 <45097959+ks129@users.noreply.github.com> Date: Mon, 18 Jan 2021 13:43:09 +0200 Subject: Relay blur handler to specific component and cleanup --- src/components/InputTypes/index.tsx | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/components/InputTypes/index.tsx b/src/components/InputTypes/index.tsx index 2481d64..cbff5e2 100644 --- a/src/components/InputTypes/index.tsx +++ b/src/components/InputTypes/index.tsx @@ -6,7 +6,7 @@ import Select from "./Select"; import ShortText from "./ShortText"; import TextArea from "./TextArea"; -import React, { ChangeEvent } from "react"; +import React, { ChangeEvent, FocusEvent } from "react"; import { QuestionType } from "../../api/question"; import { QuestionProp } from "../Question"; @@ -18,7 +18,7 @@ const require_options: Array = [ QuestionType.Range ]; -export default function create_input({ question, public_state }: QuestionProp, handler: (event: ChangeEvent) => void): JSX.Element | JSX.Element[] { +export default function create_input({ question, public_state }: QuestionProp, handler: (event: ChangeEvent) => void, blurHandler: (event: FocusEvent) => void): JSX.Element | JSX.Element[] { let result: JSX.Element | JSX.Element[]; // eslint-disable-next-line @@ -28,11 +28,6 @@ export default function create_input({ question, public_state }: QuestionProp, h if (!public_state.get("valid")) { valid = false; } - const rawError = public_state.get("error"); - let error = ""; - if (typeof rawError === "string") { - error = rawError; - } // Catch input types that require options but don't have any if ((options === undefined || typeof options !== "object") && require_options.includes(question.type)) { @@ -43,7 +38,7 @@ export default function create_input({ question, public_state }: QuestionProp, h /* eslint-disable react/react-in-jsx-scope */ switch (question.type) { case QuestionType.TextArea: - result =