fix(a11y): add role="note" to JourneyInterlude so aria-label is announced
Without a landmark or widget role, aria-label on a generic <div> is silently ignored by most screen readers (ARIA spec). Adding role="note" gives the element an ARIA role that accepts an accessible name, making the interlude label actually announced. Also adds a test asserting role="note" and the matching aria-label are both present on the same element. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ let { note }: Props = $props();
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
role="note"
|
||||||
aria-label={m.journey_interlude_aria_label()}
|
aria-label={m.journey_interlude_aria_label()}
|
||||||
class="my-2 border-l-4 border-journey-border bg-journey-tint px-4 py-3"
|
class="my-2 border-l-4 border-journey-border bg-journey-tint px-4 py-3"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -27,6 +27,14 @@ describe('JourneyInterlude', () => {
|
|||||||
expect(el).not.toBeNull();
|
expect(el).not.toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('has role="note" so the aria-label is announced by screen readers', async () => {
|
||||||
|
render(JourneyInterlude, { props: { note: 'Notiz' } });
|
||||||
|
|
||||||
|
const el = document.querySelector('[role="note"]');
|
||||||
|
expect(el).not.toBeNull();
|
||||||
|
expect(el?.getAttribute('aria-label')).toBe(m.journey_interlude_aria_label());
|
||||||
|
});
|
||||||
|
|
||||||
it('renders the section-break glyph ❦', async () => {
|
it('renders the section-break glyph ❦', async () => {
|
||||||
render(JourneyInterlude, { props: { note: 'Notiz' } });
|
render(JourneyInterlude, { props: { note: 'Notiz' } });
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user