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:
@@ -7,10 +7,11 @@ let {
|
|||||||
selectedGroupIds?: string[];
|
selectedGroupIds?: string[];
|
||||||
} = $props();
|
} = $props();
|
||||||
|
|
||||||
let selected = $derived([...selectedGroupIds]);
|
let selected = $state<string[]>([...selectedGroupIds]);
|
||||||
</script>
|
</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)}
|
{#each groups as group (group.id)}
|
||||||
<label class="inline-flex items-center gap-2 text-sm text-ink-2">
|
<label class="inline-flex items-center gap-2 text-sm text-ink-2">
|
||||||
<input
|
<input
|
||||||
@@ -23,4 +24,4 @@ let selected = $derived([...selectedGroupIds]);
|
|||||||
{group.name}
|
{group.name}
|
||||||
</label>
|
</label>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</fieldset>
|
||||||
|
|||||||
@@ -299,4 +299,39 @@ describe('admin/invites page', () => {
|
|||||||
await expect.element(page.getByRole('checkbox', { name: 'Administratoren' })).toBeVisible();
|
await expect.element(page.getByRole('checkbox', { name: 'Administratoren' })).toBeVisible();
|
||||||
await expect.element(page.getByRole('checkbox', { name: 'Familie' })).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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user