diff --git a/src/components/document-details.tsx b/src/components/document-details.tsx index 630e752..1b5e459 100644 --- a/src/components/document-details.tsx +++ b/src/components/document-details.tsx @@ -165,7 +165,7 @@ function DocumentDetailsInner(props: { id: number }) { href={`/paperless?query=${query}`} className={`${buttonVariants({ variant: "default" })}`} > - Back + Back to search {/* Download diff --git a/src/components/document-preview.tsx b/src/components/document-preview.tsx index 78a169e..e8e396f 100644 --- a/src/components/document-preview.tsx +++ b/src/components/document-preview.tsx @@ -10,6 +10,7 @@ import { Button, buttonVariants } from "@/components/ui/button"; import { ChevronLeft } from "lucide-react"; import { useRouter } from "next/navigation"; import { useSearchParams } from "next/navigation"; +import Link from "next/link"; const queryClient = new QueryClient(); @@ -95,12 +96,19 @@ export default function DocumentPreview(props: { id: number }) { - + router.replace(`/paperless/details/${props.id}?query=${query}`) + } + > + testing + + Open full page - + ); diff --git a/src/components/modal.tsx b/src/components/modal.tsx index 8ce3038..6d85cb2 100644 --- a/src/components/modal.tsx +++ b/src/components/modal.tsx @@ -12,6 +12,23 @@ export function Modal({ children }: { children: React.ReactNode }) { if (!dialogRef.current?.open) { dialogRef.current?.showModal(); } + + const closeModal = () => { + if (dialogRef.current?.open) { + dialogRef.current.close(); + } + }; + + const handleRouteChange = () => { + closeModal(); + }; + + // Listen for route changes + window.addEventListener("popstate", handleRouteChange); + + return () => { + window.removeEventListener("popstate", handleRouteChange); + }; }, []); function onDismiss() {