fix: Checklist expand — use index instead of URL (prevents all opening at once)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Benjamin Admin
2026-05-06 10:56:44 +02:00
parent 539bc824fd
commit 0416bb5d04
@@ -27,7 +27,7 @@ const DOC_TYPE_LABELS: Record<string, string> = {
} }
export function ChecklistView({ results }: { results: DocResult[] }) { export function ChecklistView({ results }: { results: DocResult[] }) {
const [expanded, setExpanded] = useState<string | null>(null) const [expanded, setExpanded] = useState<number | null>(null)
if (!results || results.length === 0) return null if (!results || results.length === 0) return null
@@ -43,7 +43,7 @@ export function ChecklistView({ results }: { results: DocResult[] }) {
<div className="space-y-2"> <div className="space-y-2">
{results.map((r, i) => { {results.map((r, i) => {
const isExp = expanded === r.url const isExp = expanded === i
const pct = r.completeness_pct const pct = r.completeness_pct
const barColor = pct === 100 ? 'bg-green-500' : pct >= 80 ? 'bg-green-400' : pct >= 50 ? 'bg-yellow-500' : 'bg-red-500' const barColor = pct === 100 ? 'bg-green-500' : pct >= 80 ? 'bg-green-400' : pct >= 50 ? 'bg-yellow-500' : 'bg-red-500'
const typeLabel = DOC_TYPE_LABELS[r.doc_type] || r.doc_type const typeLabel = DOC_TYPE_LABELS[r.doc_type] || r.doc_type
@@ -51,7 +51,7 @@ export function ChecklistView({ results }: { results: DocResult[] }) {
return ( return (
<div key={i} className="border border-gray-200 rounded-lg overflow-hidden"> <div key={i} className="border border-gray-200 rounded-lg overflow-hidden">
<button <button
onClick={() => setExpanded(isExp ? null : r.url)} onClick={() => setExpanded(isExp ? null : i)}
className="w-full flex items-center justify-between px-4 py-3 hover:bg-gray-50 text-left" className="w-full flex items-center justify-between px-4 py-3 hover:bg-gray-50 text-left"
> >
<div className="flex items-center gap-3 flex-1 min-w-0"> <div className="flex items-center gap-3 flex-1 min-w-0">