fix: add validateExam to loadSample; use native button for dropzone accessibility

This commit is contained in:
LaurensBartelds committed 2026-04-21 21:50:07 +02:00
1 parent 24d47e1830
commit ef05f2c08b
1 file changed
+5 -2
+5 -2
View File
@@ -41,6 +41,8 @@ export default function Landing({ onLoadExam, history, onResume, onClearHistory,
try {
const r = await fetch(path)
const data = await r.json() as unknown
const msg = validateExam(data)
if (msg) throw new Error(msg)
onLoadExam(parseExam(data))
} catch (e) {
setErr(`Could not load sample: ${(e as Error).message}`)
@@ -59,7 +61,8 @@ export default function Landing({ onLoadExam, history, onResume, onClearHistory,
<div className="landing-grid">
<div>
<div
<button
type="button"
className={`dropzone${dragOver ? ' drag-over' : ''}`}
onClick={() => fileRef.current?.click()}
onDragOver={(e) => { e.preventDefault(); setDragOver(true) }}
@@ -80,7 +83,7 @@ export default function Landing({ onLoadExam, history, onResume, onClearHistory,
style={{ display: 'none' }}
onChange={(e) => { const f = e.target.files?.[0]; if (f) void handleFile(f) }}
/>
</div>
</button>
{err && (
<div style={{ marginTop: 12, padding: '10px 14px', border: '1px solid var(--wrong)', borderRadius: 8, background: 'var(--wrong-weak)', color: 'var(--wrong)', fontSize: 13 }}>