Skip to content

Commit

Permalink
[DataEntry] Clear note dialog text (#2835)
Browse files Browse the repository at this point in the history
  • Loading branch information
imnasnainaec authored Dec 14, 2023
1 parent 862fb34 commit 45e7619
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/Dialogs/EditTextDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -32,9 +32,13 @@ interface EditTextDialogProps {
export default function EditTextDialog(
props: EditTextDialogProps
): ReactElement {
const [text, setText] = useState<string>(props.text);
const [text, setText] = useState("");
const { t } = useTranslation();

useEffect(() => {
setText(props.text);
}, [props.text]);

async function onConfirm(): Promise<void> {
props.close();
if (text !== props.text) {
Expand All @@ -52,7 +56,7 @@ export default function EditTextDialog(
reason: "backdropClick" | "escapeKeyDown"
): void {
if (reason === "escapeKeyDown") {
props.close();
onCancel();
}
}

Expand Down

0 comments on commit 45e7619

Please sign in to comment.