Skip to content

perf: replace window.confirm() with Dialog components #63

@macwilling

Description

@macwilling

Problem

Three places use window.confirm() — a synchronous browser API that blocks the entire JavaScript event loop, causing long tasks and poor INP scores. Chrome on Android may silently suppress it entirely.

File Issue
components/clients/ArchiveClientButton.tsx:19 window.confirm() before archive
components/tasks/AttachmentsList.tsx:139 window.confirm() before delete attachment
components/comments/CommentThread.tsx:54 window.confirm() before delete comment

Fix

Replace each window.confirm() with a controlled <Dialog> — the same pattern already used in DeleteTaskButton. Each trigger button opens the dialog instantly (zero latency), and the destructive action lives in the dialog footer.

// Pattern (ArchiveClientButton example)
const [confirmOpen, setConfirmOpen] = useState(false);

<Button onClick={() => setConfirmOpen(true)}>Archive</Button>

<Dialog open={confirmOpen} onOpenChange={setConfirmOpen}>
  <DialogContent>
    <DialogHeader>
      <DialogTitle>Archive this client?</DialogTitle>
      <DialogDescription>They will be hidden from the active client list.</DialogDescription>
    </DialogHeader>
    <DialogFooter>
      <DialogClose asChild><Button variant="outline">Cancel</Button></DialogClose>
      <Button variant="destructive" disabled={isPending} onClick={handleArchive}>
        {isPending ? "Archiving…" : "Archive"}
      </Button>
    </DialogFooter>
  </DialogContent>
</Dialog>

Acceptance criteria

  • ArchiveClientButton uses Dialog instead of window.confirm()
  • AttachmentsList delete uses Dialog instead of window.confirm()
  • CommentRow delete uses Dialog instead of window.confirm()
  • No window.confirm() or window.alert() calls remain in the codebase
  • npm run build passes

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestsize:SSmall effort

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions