diff --git a/src/components/exams/exam-questions-panel.tsx b/src/components/exams/exam-questions-panel.tsx index 51d7946..5c476a6 100644 --- a/src/components/exams/exam-questions-panel.tsx +++ b/src/components/exams/exam-questions-panel.tsx @@ -19,7 +19,6 @@ import { Alert } from "@/components/ui/alert"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { ConfirmDialog } from "@/components/ui/confirm-dialog"; -import { FormDialog } from "@/components/ui/form-dialog"; import { SidePanel } from "@/components/ui/side-panel"; import { BankQuestionPicker } from "@/components/exams/bank-question-picker"; import { QuestionForm, type QuestionValues } from "@/components/exams/question-form"; @@ -290,16 +289,23 @@ export function ExamQuestionsPanel(props: { /> - { if (!open) { - setEditing(null); - setFormOpen(false); + closeAfterGesture(() => { + setEditing(null); + setFormOpen(false); + }); } }} title={editing() ? t("questions.edit") : t("questions.add")} - description={t("questions.title")} + description={editing() ? t("questions.editHelp") : t("questions.addHelp")} > `/api/exams/${props.examId}/questions/${editing()?.id}/choices/${choiceId}/image`} loadImageBlob={editing() ? () => getExamQuestionImageBlob(props.examId, editing()!.id) : undefined} onCancel={() => { - // In-body Cancel bypasses FormDialog's deferred onOpenChange, so - // defer here too — otherwise the same tap can reopen the form. + // Deferred like the panel's own close — otherwise the same tap + // can land on the trigger underneath and reopen the form. closeAfterGesture(() => { setEditing(null); setFormOpen(false); @@ -318,7 +324,7 @@ export function ExamQuestionsPanel(props: { }} onSubmit={submit} /> - + {error() &&

{error()}

} diff --git a/src/components/exams/question-form.tsx b/src/components/exams/question-form.tsx index f50a7c0..156bb0d 100644 --- a/src/components/exams/question-form.tsx +++ b/src/components/exams/question-form.tsx @@ -58,6 +58,8 @@ export type QuestionFormInitial = { export function QuestionForm(props: { initial?: QuestionFormInitial; + /** Starting text/kind for a new question (an AI-generated draft); ignored when `initial` is set. */ + draft?: { text: string; kind: QuestionKind }; subjects: Subject[]; /** True while `subjects` is still loading, so a missing subject is not misreported. */ subjectsPending?: boolean; @@ -72,10 +74,10 @@ export function QuestionForm(props: { }) { const t = useT(); let textAreaRef: HTMLTextAreaElement | undefined; - const [text, setText] = createSignal(props.initial?.text ?? ""); + const [text, setText] = createSignal(props.initial?.text ?? props.draft?.text ?? ""); // No first-subject default: the subject is submitted, so the user picks it. const [subjectId, setSubjectId] = createSignal(props.initial?.subject ?? ""); - const [kind, setKind] = createSignal(props.initial?.kind ?? "choice"); + const [kind, setKind] = createSignal(props.initial?.kind ?? props.draft?.kind ?? "choice"); const [points, setPoints] = createSignal(String(props.initial?.points ?? 1)); const [choiceSet, setChoiceSet] = createSignal( props.initial ? storedChoiceSet(props.initial.choices, props.initial.correct) : blankChoiceSet(), @@ -99,9 +101,9 @@ export function QuestionForm(props: { createEffect(() => { const initial = props.initial; untrack(() => { - setText(initial?.text ?? ""); + setText(initial?.text ?? props.draft?.text ?? ""); setSubjectId(initial?.subject ?? ""); - setKind(initial?.kind ?? "choice"); + setKind(initial?.kind ?? props.draft?.kind ?? "choice"); setPoints(String(initial?.points ?? 1)); setChoiceSet(initial ? storedChoiceSet(initial.choices, initial.correct) : blankChoiceSet()); setImage(null); @@ -380,7 +382,10 @@ export function QuestionForm(props: {
- +
+ +

{t("questions.correctHint")}

+
- +
); diff --git a/src/components/ui/data-table.tsx b/src/components/ui/data-table.tsx index 1f82f94..2fc1143 100644 --- a/src/components/ui/data-table.tsx +++ b/src/components/ui/data-table.tsx @@ -400,7 +400,11 @@ export function DataTable(props: DataTableProps - + {/* No inner padding: the header row sits flush on the card's top edge. + A padded frame left it floating inside the card, and the sticky + header then pinned below that padding while rows scrolled through + the gap above it. */} +