From 0550b57c34726583a0917be3794064a1c70d49a7 Mon Sep 17 00:00:00 2001 From: shawn Date: Wed, 13 May 2026 12:48:55 -0400 Subject: [PATCH] Improve dialog forms and rename modals - Use form submit flows for file and thread renames - Make confirm-on-enter work in the custom alert - Update dialog styling for better mobile sizing and backdrop --- apps/web/src/components/alert.tsx | 5 ++ .../components/library-rename-modal.tsx | 84 ++++++++++--------- .../thread/components/thread-rename-modal.tsx | 83 ++++++++++-------- packages/ui/src/components/dialog.tsx | 2 +- 4 files changed, 98 insertions(+), 76 deletions(-) diff --git a/apps/web/src/components/alert.tsx b/apps/web/src/components/alert.tsx index e548b0e9..29dd54bb 100644 --- a/apps/web/src/components/alert.tsx +++ b/apps/web/src/components/alert.tsx @@ -65,6 +65,11 @@ export function CustomAlert({ className="mt-2" value={typeToConfirmValue} onChange={(e) => setTypeToConfirmValue(e.target.value)} + onKeyDown={(e) => { + if (e.key === "Enter" && !disabled) { + onConfirm(); + } + }} /> )} diff --git a/apps/web/src/features/library/components/library-rename-modal.tsx b/apps/web/src/features/library/components/library-rename-modal.tsx index 68ccf55e..acaac82c 100644 --- a/apps/web/src/features/library/components/library-rename-modal.tsx +++ b/apps/web/src/features/library/components/library-rename-modal.tsx @@ -3,16 +3,16 @@ import { useMutation } from "@tanstack/react-query"; import { toast } from "sonner"; import { useFileMutations, useLibraryStore } from "@acme/features/library"; +import { Button } from "@acme/ui/button"; import { - AlertDialog, - AlertDialogAction, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, -} from "@acme/ui/alert-dialog"; + Dialog, + DialogClose, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, +} from "@acme/ui/dialog"; import { Input } from "@acme/ui/input"; export function LibraryRenameModal() { @@ -38,44 +38,48 @@ export function LibraryRenameModal() { }); return ( - - { e.preventDefault(); inputRef.current?.focus(); }} > - - Rename File - - - - Enter a new name for the file. - - setNewFileName(e.target.value)} - placeholder="Enter a new name..." - /> - - - Cancel - { - if (!selectedFile) return; - renameFile({ id: selectedFile.id, name: newFileName }); - setLibraryRenameModalOpen(false); - setNewFileName(""); - }} - > - Rename - - - - +
{ + e.preventDefault(); + if (!selectedFile) return; + renameFile({ id: selectedFile.id, name: newFileName }); + setLibraryRenameModalOpen(false); + setNewFileName(""); + }} + > + + Rename File + + + + Enter a new name for the file. + + setNewFileName(e.target.value)} + placeholder="Enter a new name..." + /> + + + + + + + +
+ + ); } diff --git a/apps/web/src/features/thread/components/thread-rename-modal.tsx b/apps/web/src/features/thread/components/thread-rename-modal.tsx index 8f74554f..fab0e647 100644 --- a/apps/web/src/features/thread/components/thread-rename-modal.tsx +++ b/apps/web/src/features/thread/components/thread-rename-modal.tsx @@ -3,7 +3,16 @@ import { useMutation } from "@tanstack/react-query"; import { toast } from "sonner"; import { useThreadMutations, useThreadStore } from "@acme/features/thread"; -import * as Alert from "@acme/ui/alert-dialog"; +import { Button } from "@acme/ui/button"; +import { + Dialog, + DialogClose, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, +} from "@acme/ui/dialog"; import { Input } from "@acme/ui/input"; export function ThreadRenameModal() { @@ -26,7 +35,7 @@ export function ThreadRenameModal() { const inputRef = useRef(null); return ( - { if (open) { @@ -37,43 +46,47 @@ export function ThreadRenameModal() { } }} > - { e.preventDefault(); inputRef.current?.focus(); }} > - - Rename Thread - - - - Enter a new name for the thread. - - setNewThreadName(e.target.value)} - placeholder="Enter a new name..." - /> - - - Cancel - { - if (!hoveredThread) return; - renameThread({ - threadId: hoveredThread.id, - name: newThreadName, - }); - setRenameModalOpen(false); - setNewThreadName(""); - }} - > - Rename - - - - +
{ + e.preventDefault(); + if (!hoveredThread) return; + renameThread({ + threadId: hoveredThread.id, + name: newThreadName, + }); + setRenameModalOpen(false); + setNewThreadName(""); + }} + > + + Rename Thread + + + + Enter a new name for the thread. + + setNewThreadName(e.target.value)} + placeholder="Enter a new name..." + /> + + + + + + + +
+ + ); } diff --git a/packages/ui/src/components/dialog.tsx b/packages/ui/src/components/dialog.tsx index 0a1d72d4..c1b525ee 100644 --- a/packages/ui/src/components/dialog.tsx +++ b/packages/ui/src/components/dialog.tsx @@ -60,7 +60,7 @@ function DialogContent({