From 514a33483697ff231c075cbb9130606af19d9298 Mon Sep 17 00:00:00 2001
From: sowgro <tpoke.ferrari@gmail.com>
Date: Tue, 17 Dec 2024 12:47:45 -0500
Subject: Improve BMEditor

---
 extension/src/components/Bookmark.tsx | 25 +++----------------------
 1 file changed, 3 insertions(+), 22 deletions(-)

(limited to 'extension/src/components/Bookmark.tsx')

diff --git a/extension/src/components/Bookmark.tsx b/extension/src/components/Bookmark.tsx
index e378b0f..2f1bbd9 100644
--- a/extension/src/components/Bookmark.tsx
+++ b/extension/src/components/Bookmark.tsx
@@ -19,7 +19,6 @@ function Bookmark(props: {id: string}) {
     let [bgColor, setBgColor] = React.useState<[number, number, number] | null>(null)
     let [bgColorPriority, setBgColorPriority] = React.useState(0);
     const [bmData, setBmData] = useState<BookmarkTreeNode | undefined>()
-    const [renameMode, setRenameMode] = useState(false);
 
     useEffect(() => {
         getBrowser().bookmarks.get(props.id).then(r => {
@@ -44,19 +43,6 @@ function Bookmark(props: {id: string}) {
         })
     }, [bmData]);
 
-    useEffect(() => {
-        let evl = () => {
-            console.log("clicked")
-            renameMode && setRenameMode(false);
-            console.log("evl unregistered")
-            document.body.removeEventListener('click', evl);
-        }
-        if (renameMode) {
-            console.log("evl registered")
-            document.body.addEventListener('click', evl);
-        }
-    }, [renameMode]);
-
     if (!bmData) return;
 
     function handleImageLoad(e: SyntheticEvent<HTMLImageElement, Event>) {
@@ -117,7 +103,8 @@ function Bookmark(props: {id: string}) {
 
     const handleEdit = (e: React.MouseEvent<HTMLButtonElement>) => {
         e.preventDefault()
-        setRenameMode(true)
+        setActiveEdit(null);
+        setActiveEdit(bmData);
         // setActiveEdit(bmData);
     };
 
@@ -145,13 +132,7 @@ function Bookmark(props: {id: string}) {
                         }
                     })()}
                 </div>
-                {renameMode
-                    ? <input type={'text'}
-                              defaultValue={bmData.title}
-                              onChange={e => {
-                                  getBrowser().bookmarks.update(props.id, {title: e.target.value})
-                              }}/>
-                    : <span>{bmData.title}</span>}
+                <span>{bmData.title}</span>
             </a>
             {settings.editMode && <ContextMenu onEdit={handleEdit} onDelete={handleDelete}/>}
             {activeDrag && activeDrag !== bmData &&
-- 
cgit v1.2.3

