From 09e06591b2fbc3e3d81996204cfd34bd1c73db2f Mon Sep 17 00:00:00 2001
From: MohamedBassem <me@mbassem.com>
Date: Sun, 6 Oct 2024 17:48:17 +0000
Subject: fix(web): Fix sidebar list edit dialog not working. Fixes #447

---
 .../web/components/dashboard/lists/EditListModal.tsx | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

(limited to 'apps/web/components/dashboard/lists/EditListModal.tsx')

diff --git a/apps/web/components/dashboard/lists/EditListModal.tsx b/apps/web/components/dashboard/lists/EditListModal.tsx
index 993c975b..cba1a0e6 100644
--- a/apps/web/components/dashboard/lists/EditListModal.tsx
+++ b/apps/web/components/dashboard/lists/EditListModal.tsx
@@ -156,6 +156,11 @@ export function EditListModal({
   const isEdit = !!list;
   const isPending = isCreating || isEditing;
 
+  const onSubmit = form.handleSubmit((value: z.infer<typeof formSchema>) => {
+    value.parentId = value.parentId === "" ? null : value.parentId;
+    isEdit ? editList({ ...value, listId: list.id }) : createList(value);
+  });
+
   return (
     <Dialog
       open={open}
@@ -167,14 +172,7 @@ export function EditListModal({
       {children && <DialogTrigger asChild>{children}</DialogTrigger>}
       <DialogContent>
         <Form {...form}>
-          <form
-            onSubmit={form.handleSubmit((value) => {
-              value.parentId = value.parentId === "" ? null : value.parentId;
-              isEdit
-                ? editList({ ...value, listId: list.id })
-                : createList(value);
-            })}
-          >
+          <form onSubmit={onSubmit}>
             <DialogHeader>
               <DialogTitle>{isEdit ? "Edit" : "New"} List</DialogTitle>
             </DialogHeader>
@@ -264,7 +262,11 @@ export function EditListModal({
                   Close
                 </Button>
               </DialogClose>
-              <ActionButton type="submit" loading={isPending}>
+              <ActionButton
+                type="submit"
+                onClick={onSubmit}
+                loading={isPending}
+              >
                 {list ? "Save" : "Create"}
               </ActionButton>
             </DialogFooter>
-- 
cgit v1.2.3-70-g09d2

