fix(invites): make group checkboxes writable — $derived → $state

bind:group requires a writable $state variable; $derived is read-only
in Svelte 5, so every click was silently reset to unchecked, making
the group picker non-functional.

Also wraps checkboxes in <fieldset>/<legend> for WCAG 1.3.1 compliance.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-05-14 15:59:37 +02:00
committed by marcel
parent 510fa5e398
commit 3fc0ec95ef
2 changed files with 39 additions and 3 deletions

View File

@@ -7,10 +7,11 @@ let {
selectedGroupIds?: string[];
} = $props();
let selected = $derived([...selectedGroupIds]);
let selected = $state<string[]>([...selectedGroupIds]);
</script>
<div class="flex flex-wrap gap-3">
<fieldset class="flex flex-wrap gap-3 border-none p-0">
<legend class="sr-only">Gruppen</legend>
{#each groups as group (group.id)}
<label class="inline-flex items-center gap-2 text-sm text-ink-2">
<input
@@ -23,4 +24,4 @@ let selected = $derived([...selectedGroupIds]);
{group.name}
</label>
{/each}
</div>
</fieldset>

View File

@@ -299,4 +299,39 @@ describe('admin/invites page', () => {
await expect.element(page.getByRole('checkbox', { name: 'Administratoren' })).toBeVisible();
await expect.element(page.getByRole('checkbox', { name: 'Familie' })).toBeVisible();
});
it('group checkbox stays checked after being clicked', async () => {
render(AdminInvitesPage, {
props: {
data: {
...baseData(),
groups: [{ id: 'g-1', name: 'Familie', permissions: ['READ_ALL'] }],
groupsLoadError: null
}
}
});
await page
.getByRole('button', { name: /neue einladung/i })
.first()
.click();
const checkbox = page.getByRole('checkbox', { name: 'Familie' });
await checkbox.click();
await expect.element(checkbox).toBeChecked();
});
it('amber warning banner has role="alert"', async () => {
render(AdminInvitesPage, {
props: { data: { ...baseData(), groups: [], groupsLoadError: 'INTERNAL_ERROR' } }
});
await page
.getByRole('button', { name: /neue einladung/i })
.first()
.click();
const alert = document.querySelector('[role="alert"]');
expect(alert).not.toBeNull();
});
});