From 9824877648050977a48fdc5e7bea5f82ec7a6e00 Mon Sep 17 00:00:00 2001 From: Maxence Mauduit Date: Wed, 26 Aug 2026 10:11:31 +0900 Subject: [PATCH] Apply AriaAttributes to Marimekko chart --- packages/marimekko/src/Marimekko.tsx | 6 ++++++ packages/marimekko/src/types.ts | 4 ++++ packages/marimekko/tests/Marimekko.test.tsx | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/packages/marimekko/src/Marimekko.tsx b/packages/marimekko/src/Marimekko.tsx index c1f34de31d..ebe96fffdc 100644 --- a/packages/marimekko/src/Marimekko.tsx +++ b/packages/marimekko/src/Marimekko.tsx @@ -52,6 +52,9 @@ const InnerMarimekko = ({ onMouseLeave, legends = svgDefaultProps.legends, role, + ariaLabel, + ariaLabelledBy, + ariaDescribedBy, forwardedRef, }: MarimekkoSvgProps & { forwardedRef: Ref @@ -169,6 +172,9 @@ const InnerMarimekko = ({ margin={margin} defs={boundDefs} role={role} + ariaLabel={ariaLabel} + ariaLabelledBy={ariaLabelledBy} + ariaDescribedBy={ariaDescribedBy} ref={forwardedRef} > {layers.map((layer, i) => { diff --git a/packages/marimekko/src/types.ts b/packages/marimekko/src/types.ts index 596174405a..864bf3220e 100644 --- a/packages/marimekko/src/types.ts +++ b/packages/marimekko/src/types.ts @@ -1,3 +1,4 @@ +import { AriaAttributes } from 'react' import * as React from 'react' import { stackOffsetDiverging, @@ -131,6 +132,9 @@ export interface MarimekkoCommonProps { tooltip: BarTooltipType legends: readonly LegendProps[] role?: string + ariaLabel?: AriaAttributes['aria-label'] + ariaLabelledBy?: AriaAttributes['aria-labelledby'] + ariaDescribedBy?: AriaAttributes['aria-describedby'] } export type MouseEventHandler = ( diff --git a/packages/marimekko/tests/Marimekko.test.tsx b/packages/marimekko/tests/Marimekko.test.tsx index 531461c837..7f245515c0 100644 --- a/packages/marimekko/tests/Marimekko.test.tsx +++ b/packages/marimekko/tests/Marimekko.test.tsx @@ -79,3 +79,22 @@ describe('layout', () => { expect(sizes[2].height).toBeGreaterThan(sizes[0].height) }) }) + +describe('accessibility', () => { + it('should forward root aria properties to the SVG element', () => { + const wrapper = mount( + + ) + + const svg = wrapper.find('svg') + + expect(svg.prop('aria-label')).toBe('AriaLabel') + expect(svg.prop('aria-labelledby')).toBe('AriaLabelledBy') + expect(svg.prop('aria-describedby')).toBe('AriaDescribedBy') + }) +})