From 060e6c01afdc0dec763676e98a682b1a44c1e1d4 Mon Sep 17 00:00:00 2001 From: Shuveksha Tuladhar Date: Wed, 9 Oct 2024 15:26:09 -0700 Subject: [PATCH] fix(#21): close create list modal after entry --- src/views/CreateList.jsx | 7 ++++--- src/views/Disclosure.jsx | 2 +- src/views/Home.jsx | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/views/CreateList.jsx b/src/views/CreateList.jsx index 8a8cb5f..9e05628 100644 --- a/src/views/CreateList.jsx +++ b/src/views/CreateList.jsx @@ -9,11 +9,11 @@ export function CreateList({ isCreateListModalOpen, setIsCreateListModalOpen, user, + setListPath, }) { const userId = user?.uid; const userEmail = user?.email; - const [listPath, setListPath] = useState(''); const [listName, setListName] = useState(''); const handleChange = (event) => { @@ -27,6 +27,7 @@ export function CreateList({ const newListPath = await createList(userId, userEmail, listName); notify('List is sucessfully created', 'success'); setListPath(newListPath); + setIsCreateListModalOpen(false); } catch { notify('There was an error adding your list', 'error'); } @@ -58,7 +59,7 @@ export function CreateList({ setIsCreateListModalOpen(false)} - className="inline-flex justify-center rounded-md bg-[#184E77] px-4 py-[.75rem] text-lg font-medium text-white shadow-sm ring-1 ring-gray-300 hover:bg-[#1E6091] transition duration-200 ease-in-out" // Increased button padding and font size + className="inline-flex justify-center rounded-md bg-btnPrimary px-4 py-[.75rem] text-lg font-medium text-white shadow-sm ring-1 ring-gray-300 hover:bg-btnPrimary transition duration-200 ease-in-out" // Increased button padding and font size label="Cancel" IconComponent={FaTimes} /> diff --git a/src/views/Disclosure.jsx b/src/views/Disclosure.jsx index be85fa7..8da603a 100644 --- a/src/views/Disclosure.jsx +++ b/src/views/Disclosure.jsx @@ -17,7 +17,7 @@ export function Disclosure({ listpath, setListPath, }) { - const [isOpen, setIsOpen] = useState(false); + const [isOpen, setIsOpen] = useState(listpath === currentListPath); useEffect(() => { if (currentListPath !== listpath) { diff --git a/src/views/Home.jsx b/src/views/Home.jsx index 77990e9..75416c1 100644 --- a/src/views/Home.jsx +++ b/src/views/Home.jsx @@ -34,6 +34,7 @@ export function Home({ data, lists, listPath, setListPath, user }) { isCreateListModalOpen={isCreateListModalOpen} setIsCreateListModalOpen={setIsCreateListModalOpen} user={user} + setListPath={setListPath} /> )}