From 8387234f88bf4c727c9e11b0063bf237c40a1dc4 Mon Sep 17 00:00:00 2001 From: jisangs Date: Mon, 25 May 2026 18:53:22 +0900 Subject: [PATCH] =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20=ED=92=80=EC=9D=B4=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4=20focus=20=EC=A1=B0=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/game/AnswerForm.tsx | 26 ++++++++++++++++++++++++++ components/game/FeedbackPanel.tsx | 9 +++++++++ components/game/ScoreSummary.tsx | 8 ++++++++ 3 files changed, 43 insertions(+) diff --git a/components/game/AnswerForm.tsx b/components/game/AnswerForm.tsx index 871261e..a952045 100644 --- a/components/game/AnswerForm.tsx +++ b/components/game/AnswerForm.tsx @@ -1,5 +1,6 @@ "use client"; +import { useEffect, useRef } from "react"; import type { FormEvent } from "react"; interface AnswerFormProps { @@ -21,6 +22,16 @@ export default function AnswerForm({ onAnswerBChange, onSubmit, }: AnswerFormProps) { + const firstInputRef = useRef(null); + const secondInputRef = useRef(null); + const submitButtonRef = useRef(null); + + useEffect(() => { + if (!disabled) { + firstInputRef.current?.focus(); + } + }, [disabled]); + return (
첫째 항 onAnswerAChange(event.target.value)} + onKeyDown={(event) => { + if (event.key === "Enter") { + event.preventDefault(); + secondInputRef.current?.focus(); + } + }} disabled={disabled} inputMode="numeric" className="h-12 rounded-md border border-slate-300 px-4 text-lg font-semibold text-slate-950 outline-none transition focus:border-emerald-600 focus:ring-2 focus:ring-emerald-200 disabled:bg-slate-100" @@ -40,8 +58,15 @@ export default function AnswerForm({