Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: smother link from modal to details #120

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/document-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function DocumentDetailsInner(props: { id: number }) {
href={`/paperless?query=${query}`}
className={`${buttonVariants({ variant: "default" })}`}
>
Back
Back to search
</Link>
{/* <a className={buttonVariants({ variant: "default" })}>
Download
Expand Down
12 changes: 10 additions & 2 deletions src/components/document-preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -95,12 +96,19 @@ export default function DocumentPreview(props: { id: number }) {
<Button size="icon" className="bg-white" onClick={() => router.back()}>
<ChevronLeft className="h-4 w-4" color="black" />
</Button>
<a
<div
onClick={() =>
router.replace(`/paperless/details/${props.id}?query=${query}`)
}
>
testing
</div>
<Link
className={`${buttonVariants({ variant: "default" })}`}
href={`/paperless/details/${props.id}?query=${query}`}
>
Open full page
</a>
</Link>
</div>
</QueryClientProvider>
);
Expand Down
17 changes: 17 additions & 0 deletions src/components/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading