Skip to content

Commit a39ff1f

Browse files
committed
feat: added onkeydown handler
1 parent fa88372 commit a39ff1f

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

src/features/home/components/AddConnectionDialog.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,18 @@ export function AddConnectionDialog({
8989

9090
return (
9191
<Dialog open={open} onOpenChange={handleOpenChange}>
92-
<DialogContent className="sm:max-w-110 max-h-[90vh] overflow-y-auto">
92+
<DialogContent
93+
className="sm:max-w-110 max-h-[90vh] overflow-y-auto"
94+
onKeyDown={(e) => {
95+
if (e.key === "Enter") {
96+
const target = e.target as HTMLElement;
97+
if (target.tagName !== "BUTTON" && target.tagName !== "A") {
98+
e.preventDefault();
99+
if (!isLoading) handleSubmit();
100+
}
101+
}
102+
}}
103+
>
93104
<DialogHeader>
94105
<DialogTitle className="flex items-center gap-2">
95106
<Database className="h-4 w-4 text-muted-foreground" />

src/features/home/components/DeleteConnectionDialog.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,21 @@ export function DeleteConnectionDialog({
6262

6363
return (
6464
<Dialog open={open} onOpenChange={onOpenChange}>
65-
<DialogContent className="sm:max-w-[425px]">
65+
<DialogContent
66+
className="sm:max-w-[425px]"
67+
onKeyDown={(e) => {
68+
if (e.key === "Enter") {
69+
const target = e.target as HTMLElement;
70+
if (target.tagName !== "BUTTON" && target.tagName !== "A") {
71+
e.preventDefault();
72+
if (!isDeleting) {
73+
if (step === 1) handleNext();
74+
else handleConfirmDelete();
75+
}
76+
}
77+
}
78+
}}
79+
>
6680
<DialogHeader>
6781
{step === 1 ? (
6882
<>

0 commit comments

Comments
 (0)