Skip to content

Commit

Permalink
cloneDeep editedThesis to prevent cancelled changed from affecting or…
Browse files Browse the repository at this point in the history
…iginal objects
  • Loading branch information
AleksTeresh committed Sep 30, 2024
1 parent 12fafa2 commit ec3f5b8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/client/components/ThesisPage/ThesesPage.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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 = () => {
Expand Down

0 comments on commit ec3f5b8

Please sign in to comment.