test(editor): scoped overview card queries, group names

This commit is contained in:
bchanot committed 2026-11-07 03:03:39 +01:00
1 parent 6131225288
commit 7cca88592f
4 files changed
+92 -43

No files matched your search

@@ -58,12 +58,12 @@ function Row({
}
/** « Sans catégorie » or the category: swatch, name and the count of rows shown. */
function GroupTitle({ group }: { group: AnnotationGroup }) {
function GroupTitle({ group, id }: { group: AnnotationGroup; id: string }) {
const t = useT()
const locale = useLocaleStore((s) => s.locale)
const { category } = group
return (
<p className="flex items-center gap-2 px-3 text-sm font-semibold">
<p id={id} className="flex items-center gap-2 px-3 text-sm font-semibold">
<span
aria-hidden="true"
className="size-3 rounded-full border border-[var(--color-border)]"
@@ -86,30 +86,36 @@ function GroupTitle({ group }: { group: AnnotationGroup }) {
export default function AnnotationList({
groups,
views,
idPrefix = '',
onSelect,
}: {
groups: readonly AnnotationGroup[]
views: readonly SheetView[]
/** Put before every id (the read-only twin beside the kept edit panel). */
idPrefix?: string
onSelect: (id: string) => void
}) {
const t = useT()
return (
<ul aria-label={t('editor.annotations.list')} className={LIST}>
{groups.map((group) => (
<li key={group.category?.id ?? 'none'}>
<GroupTitle group={group} />
<ul>
{group.annotations.map((annotation) => (
<Row
key={annotation.id}
annotation={annotation}
views={views}
onSelect={onSelect}
/>
))}
</ul>
</li>
))}
{groups.map((group) => {
const id = `${idPrefix}overview-group-${group.category?.id ?? 'none'}`
return (
<li key={id}>
<GroupTitle group={group} id={id} />
<ul aria-labelledby={id}>
{group.annotations.map((annotation) => (
<Row
key={annotation.id}
annotation={annotation}
views={views}
onSelect={onSelect}
/>
))}
</ul>
</li>
)
})}
</ul>
)
}
@@ -227,6 +227,7 @@ function AnnotationsCard(props: OverviewPanelProps) {
<AnnotationList
groups={groups}
views={doc.views}
idPrefix={prefix}
onSelect={onSelectAnnotation}
/>
) : (