From ec3f5b8cc7b2483e24d8b2e8619bee92762458fc Mon Sep 17 00:00:00 2001 From: Tereshchenko Aleksandr Date: Mon, 30 Sep 2024 14:50:18 +0300 Subject: [PATCH] cloneDeep editedThesis to prevent cancelled changed from affecting original objects --- src/client/components/ThesisPage/ThesesPage.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/client/components/ThesisPage/ThesesPage.tsx b/src/client/components/ThesisPage/ThesesPage.tsx index 89f8174..3f15d66 100644 --- a/src/client/components/ThesisPage/ThesesPage.tsx +++ b/src/client/components/ThesisPage/ThesesPage.tsx @@ -1,6 +1,7 @@ import dayjs from 'dayjs' import { useEffect, useMemo, useRef, useState } from 'react' import { Trans, useTranslation } from 'react-i18next' +import { cloneDeep } from 'lodash-es' import { Box, Stack, TextField, Typography } from '@mui/material' import { @@ -227,7 +228,9 @@ const ThesesPage = () => { (thesis) => thesis.id === rowSelectionModel[0] ) - setEditedThesis(thesisToEdit) + // NOTE: We need to clone the object to + // prevent the form from updating the original object + setEditedThesis(cloneDeep(thesisToEdit)) } const clearRowSelection = () => {