From 2c31ecd5fd896e5f0a43f4a689dbb60a36c39431 Mon Sep 17 00:00:00 2001 From: dobri1408 <50819975+dobri1408@users.noreply.github.com> Date: Thu, 28 Mar 2024 09:05:46 +0200 Subject: [PATCH] Update Edit.jsx --- src/components/Blocks/Hero/Edit.jsx | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/components/Blocks/Hero/Edit.jsx b/src/components/Blocks/Hero/Edit.jsx index ab3b882..5445ba6 100644 --- a/src/components/Blocks/Hero/Edit.jsx +++ b/src/components/Blocks/Hero/Edit.jsx @@ -62,11 +62,11 @@ export default function Edit(props) { const blockState = {}; const data_blocks = data?.data?.blocks; if (data?.text || isEmpty(data_blocks)) { - let a = { ...data }; - if (a.text) delete a.text; + let dataWithoutText = { ...data }; + if (dataWithoutText) delete dataWithoutText.text; onChangeBlock(block, { - ...a, + ...dataWithoutText, data: data?.text ? { blocks: { @@ -99,20 +99,16 @@ export default function Edit(props) { setSelectedBlock(s); }} onChangeFormData={(newFormData) => { - let a = { ...data }; - if (a.text) delete a.text; onChangeBlock(block, { - ...a, + ...data, data: newFormData, }); }} onChangeField={(id, value) => { if (['blocks', 'blocks_layout'].indexOf(id) > -1) { blockState[id] = value; - let a = { ...data }; - if (a.text) delete a.text; onChangeBlock(block, { - ...a, + ...data, data: { ...data.data, ...blockState,