π¬ A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots π
TypeScript browser-extensionchrome-extensiondocumentationfirefox-extensionguide-generatorlocal-firstmanifest-v3privacy-firstproductivityreactscreenshotstep-by-step-guidetutorialtypescriptworkflowwxt
fix(ui): replace native confirm dialogs with in-app dialogs
Luis Ortiz2bcfb82d32e1
diff --git a/src/ui/shared/ConfirmDialog.tsx b/src/ui/shared/ConfirmDialog.tsxnew file mode 100644index 0000000..fdcfbfb--- /dev/null+++ b/src/ui/shared/ConfirmDialog.tsx@@ -0,0 +1,49 @@+import { i18n } from '#imports';+import { Button } from '@/ui/components/ui/button';+import {+ Dialog,+ DialogContent,+ DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogTitle,+} from '@/ui/components/ui/dialog';++interface ConfirmDialogProps {+ open: boolean;+ title: string;+ description?: string;+ confirmLabel?: string;+ destructive?: boolean;+ onConfirm: () => void;+ onCancel: () => void;+}++export default function ConfirmDialog({+ open,+ title,+ description,+ confirmLabel,+ destructive = false,+ onConfirm,+ onCancel,+}: ConfirmDialogProps) {+ return (+ <Dialog open={open} onOpenChange={(next) => !next && onCancel()}>+ <DialogContent className="sm:max-w-[360px]">+ <DialogHeader>+ <DialogTitle>{title}</DialogTitle>+ {description && <DialogDescription>{description}</DialogDescription>}+ </DialogHeader>+ <DialogFooter>+ <Button variant="outline" size="sm" onClick={onCancel}>+ {i18n.t('common.cancel')}+ </Button>+ <Button variant={destructive ? 'destructive' : 'default'} size="sm" onClick={onConfirm}>+ {confirmLabel ?? i18n.t('common.delete')}+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>+ );+}diff --git a/src/ui/shared/ScreenshotView.tsx b/src/ui/shared/ScreenshotView.tsxindex 7d9b0b4..ecc6384 100644--- a/src/ui/shared/ScreenshotView.tsx+++ b/src/ui/shared/ScreenshotView.tsx@@ -15,6 +15,7 @@ import {DropdownMenuTrigger,} from '@/ui/components/ui/dropdown-menu';import { Popover, PopoverContent, PopoverTrigger } from '@/ui/components/ui/popover';+import ConfirmDialog from '@/ui/shared/ConfirmDialog';interface ScreenshotViewProps {screenshot: Screenshot;@@ -83,6 +84,7 @@ export default function ScreenshotView({const [deleted, setDeleted] = useState(false);const [saved, setSaved] = useState(false);const [altDraft, setAltDraft] = useState('');+ const [confirmDelete, setConfirmDelete] = useState(false);const processedKeyRef = useRef<string | null>(null);const urlRef = useRef<string | null>(null);const idRef = useRef(screenshot.id);@@ -286,7 +288,7 @@ export default function ScreenshotView({};const handleDeleteImage = async () => {- if (!window.confirm(i18n.t('screenshotView.deleteConfirm'))) return;+ setConfirmDelete(false);await deleteScreenshot(screenshot.id, screenshot.stepId);setDeleted(true);};@@ -425,13 +427,21 @@ export default function ScreenshotView({{i18n.t('screenshotView.download')}</DropdownMenuItem><DropdownMenuSeparator />- <DropdownMenuItem variant="destructive" onSelect={handleDeleteImage}>+ <DropdownMenuItem variant="destructive" onSelect={() => setConfirmDelete(true)}><Trash2 size={14} />{i18n.t('screenshotView.deleteImage')}</DropdownMenuItem></DropdownMenuContent></DropdownMenu><input ref={fileInputRef} type="file" accept="image/*" className="hidden" onChange={handleFileChange} />+ <ConfirmDialog+ open={confirmDelete}+ title={i18n.t('screenshotView.deleteImage')}+ description={i18n.t('screenshotView.deleteConfirm')}+ destructive+ onConfirm={handleDeleteImage}+ onCancel={() => setConfirmDelete(false)}+ /></div>)}{!readOnly && saved && (diff --git a/src/ui/sidepanel/StepCard.tsx b/src/ui/sidepanel/StepCard.tsxindex 413c0cf..d5f04ec 100644--- a/src/ui/sidepanel/StepCard.tsx+++ b/src/ui/sidepanel/StepCard.tsx@@ -4,6 +4,7 @@ import { i18n } from '#imports';import type { Screenshot, Step } from '@/core/guides/types';import { renderScreenshot } from '@/core/screenshot/render';import { logger } from '@/lib/logger';+import ConfirmDialog from '@/ui/shared/ConfirmDialog';import ScreenshotView from '@/ui/shared/ScreenshotView';interface DragHandleProps {@@ -34,6 +35,7 @@ export default function StepCard({const [dragOver, setDragOver] = useState(false);const [copied, setCopied] = useState(false);const pressedOnScreenshot = useRef(false);+ const [confirmDelete, setConfirmDelete] = useState(false);useEffect(() => {setDescription(step.description);@@ -44,7 +46,8 @@ export default function StepCard({};const handleDelete = () => {- if (window.confirm(i18n.t('editor.deleteThisStep'))) onDelete(step.id);+ setConfirmDelete(false);+ onDelete(step.id);};const handleCopy = async () => {@@ -127,7 +130,7 @@ export default function StepCard({</button>)}<button- onClick={handleDelete}+ onClick={() => setConfirmDelete(true)}className="p-1 rounded-md transition-colors text-border hover:text-destructive"title={i18n.t('recording.deleteStep')}>@@ -136,6 +139,13 @@ export default function StepCard({</div></div></div>+ <ConfirmDialog+ open={confirmDelete}+ title={i18n.t('editor.deleteThisStep')}+ destructive+ onConfirm={handleDelete}+ onCancel={() => setConfirmDelete(false)}+ /></div>);}