From 7f3c647328fbf3d248b3b4906a350314754028e9 Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Sat, 7 Mar 2026 02:21:23 +0530 Subject: [PATCH] feat: implement mobile long-press functionality in DocumentsTableShell for enhanced document interaction, and integrate Drawer components for improved UI consistency --- .../components/DocumentsTableShell.tsx | 274 +++++++++++++----- 1 file changed, 207 insertions(+), 67 deletions(-) diff --git a/surfsense_web/app/dashboard/[search_space_id]/documents/(manage)/components/DocumentsTableShell.tsx b/surfsense_web/app/dashboard/[search_space_id]/documents/(manage)/components/DocumentsTableShell.tsx index 352be37d8..13b55c4f3 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/documents/(manage)/components/DocumentsTableShell.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/documents/(manage)/components/DocumentsTableShell.tsx @@ -40,6 +40,13 @@ import { ContextMenuTrigger, } from "@/components/ui/context-menu"; import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog"; +import { + Drawer, + DrawerContent, + DrawerHandle, + DrawerHeader, + DrawerTitle, +} from "@/components/ui/drawer"; import { Skeleton } from "@/components/ui/skeleton"; import { Spinner } from "@/components/ui/spinner"; import { @@ -271,6 +278,48 @@ function RowContextMenu({ ); } +function MobileCardWrapper({ + onLongPress, + children, +}: { + onLongPress: () => void; + children: React.ReactNode; +}) { + const timerRef = useRef | null>(null); + const didLongPressRef = useRef(false); + + const clearTimer = useCallback(() => { + if (timerRef.current) { + clearTimeout(timerRef.current); + timerRef.current = null; + } + }, []); + + return ( + // biome-ignore lint/a11y/useSemanticElements: touch-only long-press wrapper for mobile +
{ + didLongPressRef.current = false; + timerRef.current = setTimeout(() => { + didLongPressRef.current = true; + onLongPress(); + }, 500); + }} + onTouchMove={clearTimer} + onTouchEnd={(e) => { + clearTimer(); + if (didLongPressRef.current) { + e.preventDefault(); + } + }} + onContextMenu={(e) => e.preventDefault()} + > + {children} +
+ ); +} + export function DocumentsTableShell({ documents, loading, @@ -313,6 +362,8 @@ export function DocumentsTableShell({ const [deleteDoc, setDeleteDoc] = useState(null); const [isDeleting, setIsDeleting] = useState(false); + const [mobileActionDoc, setMobileActionDoc] = useState(null); + const router = useRouter(); const desktopSentinelRef = useRef(null); const mobileSentinelRef = useRef(null); @@ -657,83 +708,85 @@ export function DocumentsTableShell({ } }; return ( - -
- {canInteract && hasChatMode && ( - + {mobileActionDoc && + EDITABLE_DOCUMENT_TYPES.includes( + mobileActionDoc.document_type as (typeof EDITABLE_DOCUMENT_TYPES)[number] + ) && ( + + )} + {mobileActionDoc && + !NON_DELETABLE_DOCUMENT_TYPES.includes( + mobileActionDoc.document_type as (typeof NON_DELETABLE_DOCUMENT_TYPES)[number] + ) && ( + + )} +
+ + ); }