From 80fec5502292cddf347de337687014dc3882fbb6 Mon Sep 17 00:00:00 2001 From: Gslmao Date: Thu, 4 Jun 2026 09:27:12 +0530 Subject: [PATCH 1/3] fix: fixed sharebutton's behaviour during fullscreen --- src/components/ShareButton.tsx | 48 +++++++++++-------- src/components/newPdfViewer.tsx | 85 +++++++++++++++++---------------- src/components/ui/dialog.tsx | 6 ++- 3 files changed, 76 insertions(+), 63 deletions(-) diff --git a/src/components/ShareButton.tsx b/src/components/ShareButton.tsx index e06c7a6..0759df1 100644 --- a/src/components/ShareButton.tsx +++ b/src/components/ShareButton.tsx @@ -1,14 +1,15 @@ "use client"; -import React, { useEffect, useState } from "react"; +import React, { useEffect, useRef, useState } from "react"; import { Dialog, - DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, + DialogContent, } from "./ui/dialog"; +import * as DialogPrimitive from "@radix-ui/react-dialog"; import { Copy } from "lucide-react"; import toast from "react-hot-toast"; import { FaShare } from "react-icons/fa"; @@ -16,25 +17,35 @@ import QR from "./qr"; import { Button } from "./ui/button"; import { usePathname } from "next/navigation"; -export default function ShareButton() { +interface ShareButtonProps { + isFullscreen: boolean; + viewerRef: React.RefObject; +} + +export default function ShareButton({ isFullscreen, viewerRef }: ShareButtonProps) { const [origin, setOrigin] = useState(""); + const pathname = usePathname(); useEffect(() => { - if (typeof window !== "undefined") { - setOrigin(window.location.origin); - } + setOrigin(window.location.origin); }, []); - const pathname = usePathname(); const paperPath = origin + pathname; + console.log("isFullscreen:", isFullscreen, "container:", isFullscreen ? viewerRef.current : document.body); return ( - - + Share Papers with your friends! @@ -42,21 +53,18 @@ export default function ShareButton() {
- +
); -} +} \ No newline at end of file diff --git a/src/components/newPdfViewer.tsx b/src/components/newPdfViewer.tsx index a2c47ab..634765e 100644 --- a/src/components/newPdfViewer.tsx +++ b/src/components/newPdfViewer.tsx @@ -25,6 +25,7 @@ interface ControlProps { forceMobile?: boolean; isMobile: boolean; isSmall: boolean; + viewerRef: React.RefObject; } interface PdfViewerProps { @@ -57,7 +58,7 @@ function useBreakpoint() { } const Controls = memo(function Controls({documentId, toggleFullscreen, isFullscreen, onDownload, - forceMobile, isMobile, isSmall}: ControlProps) { + forceMobile, isMobile, isSmall, viewerRef}: ControlProps) { const { provides: zoomProv, state: zoomState } = useZoom(documentId); const { provides: scrollProv, state: scrollState } = useScroll(documentId); @@ -127,7 +128,7 @@ const Controls = memo(function Controls({documentId, toggleFullscreen, isFullscr - +