From 66f6e2803f272060c0dcbf9d384e688b91ee4269 Mon Sep 17 00:00:00 2001
From: daedalus <44623501+ComfortablyCoding@users.noreply.github.com>
Date: Thu, 12 Oct 2023 20:07:58 -0400
Subject: [PATCH] fix(admin): close/cancel do not close note modal (#19)
---
admin/src/components/NoteListLayout/NoteListLayout.js | 11 +++++++++--
admin/src/components/NoteModal/NoteModal.js | 10 +++++-----
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/admin/src/components/NoteListLayout/NoteListLayout.js b/admin/src/components/NoteListLayout/NoteListLayout.js
index 8e6dcc8..c4f65eb 100644
--- a/admin/src/components/NoteListLayout/NoteListLayout.js
+++ b/admin/src/components/NoteListLayout/NoteListLayout.js
@@ -83,13 +83,20 @@ const NoteListLayout = () => {
label="Notes"
startIcon={}
disabled={isLoading}
- onClick={() => setIsNoteModalVisible(true)}
+ onClick={() => {
+ setActiveNote({});
+ setIsNoteModalVisible(true);
+ }}
marginTop={4}
>
Add a note
{isNoteModalVisible && (
-
+
)}
);
diff --git a/admin/src/components/NoteModal/NoteModal.js b/admin/src/components/NoteModal/NoteModal.js
index 449d8a6..aafa63e 100644
--- a/admin/src/components/NoteModal/NoteModal.js
+++ b/admin/src/components/NoteModal/NoteModal.js
@@ -16,7 +16,7 @@ import { Check } from '@strapi/icons';
import { useNote } from '../../hooks/useNote';
import { getTrad } from '../../utils';
-const NoteModal = ({ entity, note = {}, toggleModal }) => {
+const NoteModal = ({ entity, note = {}, setIsNoteModalVisible }) => {
const [entityNote, setEntityNote] = useState(note);
const { createNote, updateNote } = useNote();
const { formatMessage } = useIntl();
@@ -44,7 +44,7 @@ const NoteModal = ({ entity, note = {}, toggleModal }) => {
} catch (error) {
console.error(error);
}
- toggleModal(false);
+ setIsNoteModalVisible(false);
};
const updateState = (key, value) => {
@@ -58,7 +58,7 @@ const NoteModal = ({ entity, note = {}, toggleModal }) => {
};
return (
-
+ setIsNoteModalVisible(false)} labelledBy="title">
{formatMessage({
@@ -83,7 +83,7 @@ const NoteModal = ({ entity, note = {}, toggleModal }) => {
+