From 45e76196de915a88e13c1a5dc3db57e679874a6e Mon Sep 17 00:00:00 2001 From: "D. Ror" Date: Thu, 14 Dec 2023 13:55:15 -0500 Subject: [PATCH] [DataEntry] Clear note dialog text (#2835) --- src/components/Dialogs/EditTextDialog.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/Dialogs/EditTextDialog.tsx b/src/components/Dialogs/EditTextDialog.tsx index 976a3c4d88..8c53b8272f 100644 --- a/src/components/Dialogs/EditTextDialog.tsx +++ b/src/components/Dialogs/EditTextDialog.tsx @@ -9,7 +9,7 @@ import { InputAdornment, TextField, } from "@mui/material"; -import React, { ReactElement, useState } from "react"; +import React, { ReactElement, useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { Key } from "ts-key-enum"; @@ -32,9 +32,13 @@ interface EditTextDialogProps { export default function EditTextDialog( props: EditTextDialogProps ): ReactElement { - const [text, setText] = useState(props.text); + const [text, setText] = useState(""); const { t } = useTranslation(); + useEffect(() => { + setText(props.text); + }, [props.text]); + async function onConfirm(): Promise { props.close(); if (text !== props.text) { @@ -52,7 +56,7 @@ export default function EditTextDialog( reason: "backdropClick" | "escapeKeyDown" ): void { if (reason === "escapeKeyDown") { - props.close(); + onCancel(); } }