Skip to content

Commit eac063f

Browse files
committed
fix(modals): focus name input on validation and update placeholder
1 parent 85548f8 commit eac063f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/components/modals/NewConnectionModal.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState, useEffect } from "react";
1+
import { useState, useEffect, useRef } from "react";
22
import { useTranslation } from "react-i18next";
33
import {
44
X,
@@ -163,6 +163,7 @@ export const NewConnectionModal = ({
163163

164164
// ── validation errors ──
165165
const [nameError, setNameError] = useState(false);
166+
const nameInputRef = useRef<HTMLInputElement>(null);
166167
const [databasesTabError, setDatabasesTabError] = useState(false);
167168

168169
// ── capabilities ──
@@ -405,6 +406,7 @@ export const NewConnectionModal = ({
405406
setMessage(t("newConnection.nameRequired"));
406407
setTestResult("error");
407408
setNameError(true);
409+
nameInputRef.current?.focus();
408410
return;
409411
}
410412
if (isMultiDb) {
@@ -1103,6 +1105,7 @@ export const NewConnectionModal = ({
11031105
style={getDriverColorStyle(activeDriver)}
11041106
/>
11051107
<input
1108+
ref={nameInputRef}
11061109
type="text"
11071110
value={name}
11081111
onChange={(e) => {

src/i18n/locales/en.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@
410410
"titleEdit": "Edit Connection",
411411
"subtitle": "Configure database connection settings",
412412
"name": "Connection Name",
413-
"namePlaceholder": "My Production DB",
413+
"namePlaceholder": "Provide your connection name",
414414
"nameRequired": "Connection name is required",
415415
"dbNameRequired": "Database name is required",
416416
"dbType": "Database Type",
@@ -867,4 +867,4 @@
867867
"dragHint": "Drag connections here",
868868
"createError": "Failed to create group"
869869
}
870-
}
870+
}

0 commit comments

Comments
 (0)