-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
[bug]: long press image in dialog with modal mode in PWA, context menu doesn't show #7087
Open
2 tasks done
Labels
bug
Something isn't working
Comments
An interesting find, is set onPointerDownOutside={(e) => e.preventDefault()}
onInteractOutside={(e) => e.preventDefault()} Updated demo code "use client"
import { useState } from "react"
import { Button } from "@/components/ui/button"
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
import Image from "next/image"
export default function Home() {
const [open, setOpen] = useState(false)
const [open2, setOpen2] = useState(false)
return (
<main className="flex min-h-screen flex-col items-center justify-center p-4">
<h1 className="mb-8 text-3xl font-bold">Next.js PWA Example</h1>
<div className="relative bg-indigo-500 w-[300px] h-[200px] mx-auto mb-10">
<Image
src="/placeholder.svg?height=400&width=600"
alt="Example image"
fill
className="object-cover w-full h-full"
priority
/>
</div>
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>
<Button size="lg">Open Image Dialog</Button>
</DialogTrigger>
<DialogContent className="sm:max-w-md">
<DialogHeader>
<DialogTitle>Image Preview</DialogTitle>
<DialogDescription>This is an example image in a dialog for our PWA.</DialogDescription>
</DialogHeader>
<div className="relative aspect-video overflow-hidden rounded-lg">
<Image
src="/placeholder.svg?height=400&width=600"
alt="Example image"
fill
className="object-cover"
priority
/>
</div>
</DialogContent>
</Dialog>
<div className="mb-4"></div>
<Dialog open={open2} onOpenChange={setOpen2} modal={false}>
<DialogTrigger asChild>
<Button size="lg">Open Image Dialog with "modal=false"</Button>
</DialogTrigger>
<DialogContent
className="sm:max-w-md"
onPointerDownOutside={(e) => e.preventDefault()}
onInteractOutside={(e) => e.preventDefault()}
>
<DialogHeader>
<DialogTitle>Image Preview without modal mode</DialogTitle>
<DialogDescription>This is an example image in a dialog without modal mode.</DialogDescription>
</DialogHeader>
<div className="relative aspect-video overflow-hidden rounded-lg">
<Image
src="/placeholder.svg?height=400&width=600"
alt="Example image"
fill
className="object-cover"
priority
/>
</div>
</DialogContent>
</Dialog>
<p className="mt-8 text-center text-sm text-muted-foreground">
This is a Progressive Web App. You can install it on your device!
</p>
</main>
)
} You could easily long press image in 2nd dialog to save it picture library with context menu. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Long press image in dialog may not trigger image's context menu to save to photo library.
Affected component/components
Dialog, Image
How to reproduce
Codesandbox/StackBlitz link
https://v0-next-js-pwa-dialog.vercel.app/
Logs
System Info
Before submitting
The text was updated successfully, but these errors were encountered: