From 697291fe66f8bed4b639e87e727bcae5cee7ce68 Mon Sep 17 00:00:00 2001 From: 1ilit Date: Thu, 14 Mar 2024 00:27:09 +0200 Subject: [PATCH] Fix setSelectedElement in contexts --- src/context/AreasContext.jsx | 8 ++++---- src/context/NotesContext.jsx | 8 ++++---- src/context/TablesContext.jsx | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/context/AreasContext.jsx b/src/context/AreasContext.jsx index 88eb692..e29f9ac 100644 --- a/src/context/AreasContext.jsx +++ b/src/context/AreasContext.jsx @@ -63,12 +63,12 @@ export default function AreasContextProvider({ children }) { prev.filter((e) => e.id !== id).map((e, i) => ({ ...e, id: i })) ); if (id === selectedElement.id) { - setSelectedElement({ + setSelectedElement((prev) => ({ + ...prev, element: ObjectType.NONE, id: -1, - openDialogue: false, - openCollapse: false, - }); + open: false, + })); } }; diff --git a/src/context/NotesContext.jsx b/src/context/NotesContext.jsx index 6b2b69a..2acf498 100644 --- a/src/context/NotesContext.jsx +++ b/src/context/NotesContext.jsx @@ -63,12 +63,12 @@ export default function NotesContextProvider({ children }) { prev.filter((e) => e.id !== id).map((e, i) => ({ ...e, id: i })) ); if (id === selectedElement.id) { - setSelectedElement({ + setSelectedElement((prev) => ({ + ...prev, element: ObjectType.NONE, id: -1, - openDialogue: false, - openCollapse: false, - }); + open: false, + })); } }; diff --git a/src/context/TablesContext.jsx b/src/context/TablesContext.jsx index 13f323d..a5ab5c6 100644 --- a/src/context/TablesContext.jsx +++ b/src/context/TablesContext.jsx @@ -94,12 +94,12 @@ export default function TablesContextProvider({ children }) { return prev.filter((e) => e.id !== id).map((e, i) => ({ ...e, id: i })); }); if (id === selectedElement.id) { - setSelectedElement({ + setSelectedElement((prev) => ({ + ...prev, element: ObjectType.NONE, id: -1, - openDialogue: false, - openCollapse: false, - }); + open: false, + })); } };