fix(search): derive disambiguation trigger aria-label from match count (#763 review)

The trigger hardcoded the multiple-people label for every count, so a
single did-you-mean picker announced "Mehrere Personen gefunden" to
screen readers while sighted users saw one name and a "Meintest du …?"
heading. Derive the trigger's accessible name from persons.length: a
single suggestion reuses the heading prop, two or more keep the
multiple-people label. Visible truncated name span unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-06-07 01:26:30 +02:00
committed by marcel
parent 6959651b36
commit 8429b1e9f8
2 changed files with 24 additions and 2 deletions

View File

@@ -25,6 +25,9 @@ let listEl = $state<HTMLUListElement>();
const panelId = 'disambiguation-panel';
const headingId = 'disambiguation-heading';
const names = $derived(persons.map((person) => person.displayName).join(', '));
const triggerLabel = $derived(
persons.length === 1 ? heading : m.search_disambiguation_trigger_label()
);
async function openPicker() {
open = true;
@@ -64,7 +67,7 @@ function onKeydown(event: KeyboardEvent) {
aria-haspopup="true"
aria-expanded={open}
aria-controls={panelId}
aria-label={m.search_disambiguation_trigger_label()}
aria-label={triggerLabel}
onclick={toggle}
class="inline-flex min-h-[44px] items-center gap-1.5 rounded-full border border-line bg-muted px-3 text-sm text-ink-2 outline-none focus-visible:ring-2 focus-visible:ring-brand-navy"
>