From 93fb66dc2eb144f0eeb850ad2d57ff1233ca8edf Mon Sep 17 00:00:00 2001 From: corgifist Date: Sun, 27 Jul 2025 02:07:01 +0300 Subject: [PATCH] fixed annoying project selection bug (using pretty ugly way tho lol) --- src/app/page.tsx | 76 ++++++++++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 31 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index a8ac89f..6a2a4b9 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,6 +1,6 @@ "use client"; import { SidebarTrigger } from "@/components/ui/sidebar"; -import { createContext, Dispatch, ReactNode, SetStateAction, useContext, useEffect, useState } from "react"; +import { createContext, Dispatch, MouseEventHandler, ReactNode, SetStateAction, useContext, useEffect, useState } from "react"; import { useLiveQuery } from "dexie-react-hooks"; import { addProject, db, deleteProject } from "@/lib/db"; import { Label } from "@/components/ui/label"; @@ -28,7 +28,7 @@ import { Checkbox } from "@/components/ui/checkbox"; import { cn } from "@/lib/utils"; import { Tooltip, TooltipContent } from "@/components/ui/tooltip"; import { TooltipTrigger } from "@radix-ui/react-tooltip"; -import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, SheetTrigger } from "@/components/ui/sheet"; +import { Sheet, SheetClose, SheetContent, SheetDescription, SheetHeader, SheetTitle, SheetTrigger } from "@/components/ui/sheet"; import { Separator } from "@/components/ui/separator"; type SortingType = "byCreationDate" @@ -244,25 +244,35 @@ const ProjectDropdown = ({ Rename - Manage {project.title} + Actions for {project.title} - - - - - - - + + + + + + + + + + + + + + + + + @@ -271,7 +281,7 @@ const ProjectDropdown = ({ - ) + ); } return ( @@ -350,7 +360,11 @@ const ProjectContainer = ({ if (!selecting && selected) setSelected(false); const date = new Date(project.editDate); - const handleClick = () => { + + // TODO: data-selectable is a really dirty way of deciding whether to trigger selection or not should be reworked in the future + const handleClick = (e: React.MouseEvent) => { + if ((e.target as HTMLDivElement).getAttribute("data-selectable") != "true") return; + e.stopPropagation(); if (selecting) { setSelected(!selected); } @@ -374,16 +388,16 @@ const ProjectContainer = ({ }, [selected]); return ( - - -
-
-
-

{project.title}

- {project.description &&

{project.description}

} - {project.editDate &&

Last edit date: {date.toLocaleDateString()}, {date.toLocaleTimeString()}

} + + +
+
+
+

{project.title}

+ {project.description &&

{project.description}

} + {project.editDate &&

Last Edit Date: {date.toLocaleDateString()}, {date.toLocaleTimeString()}

}
-
+
{!selecting && }