From cb6be7c634839e60fd0be9171f3a2f61e7399eae Mon Sep 17 00:00:00 2001 From: NixReaper Date: Sat, 25 Apr 2026 21:21:45 -0500 Subject: [PATCH] fix: move FormField outside CreateAccount to prevent input focus loss on keystroke --- nixserver/src/App.tsx | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/nixserver/src/App.tsx b/nixserver/src/App.tsx index eb0220b..f00f0e5 100644 --- a/nixserver/src/App.tsx +++ b/nixserver/src/App.tsx @@ -435,6 +435,25 @@ function ListAccounts({ onNav }: { onNav: (p: Page) => void }) { ) } +/* ── Reusable form field — defined at module level to avoid remount bug ───── */ +function FormField({ label, type = 'text', placeholder = '', value, onChange }: { + label: string; type?: string; placeholder?: string + value: string; onChange: (v: string) => void +}) { + return ( +
+ + onChange(e.target.value)} + placeholder={placeholder} + className="w-full bg-[#0f1520] border border-[#2a3044] text-white rounded px-3 py-2 text-sm placeholder-gray-600 focus:outline-none focus:border-orange-500/60" + /> +
+ ) +} + /* ── Create account form ─────────────────────────────────────────────────── */ function CreateAccount({ onNav }: { onNav: (p: Page) => void }) { const [form, setForm] = useState({ @@ -442,7 +461,7 @@ function CreateAccount({ onNav }: { onNav: (p: Page) => void }) { package_name: 'Default', disk_quota_mb: 10240, bandwidth_mb: 0, }) const [loading, setLoading] = useState(false) - const [error, setError] = useState('') + const [error, setError] = useState('') const [success, setSuccess] = useState('') const set = (k: string, v: string | number) => setForm(f => ({ ...f, [k]: v })) @@ -465,16 +484,6 @@ function CreateAccount({ onNav }: { onNav: (p: Page) => void }) { } } - const Field = ({ label, name, type = 'text', placeholder = '' }: { label: string; name: string; type?: string; placeholder?: string }) => ( -
- - set(name, e.target.value)} - placeholder={placeholder} - className="w-full bg-[#0f1520] border border-[#2a3044] text-white rounded px-3 py-2 text-sm placeholder-gray-600 focus:outline-none focus:border-orange-500/60" - /> -
- ) - return (

Create Hosting Account

@@ -485,16 +494,16 @@ function CreateAccount({ onNav }: { onNav: (p: Page) => void }) {

Domain Information

- + set('domain', v)} placeholder="example.com" />

Account Credentials

- - + set('username', v)} placeholder="username" /> + set('password', v)} placeholder="••••••••" type="password" />
- + set('email', v)} placeholder="user@example.com" type="email" />