diff --git a/src/components/Button/Button.tsx b/src/components/Button/Button.tsx index 6f07113572..98b2c7e6ca 100644 --- a/src/components/Button/Button.tsx +++ b/src/components/Button/Button.tsx @@ -171,6 +171,7 @@ const Button = ({ textColor: customTextColor, children, 'aria-label': ariaLabel, + 'aria-expanded': ariaExpanded, accessibilityHint, role = 'button', hitSlop, @@ -328,6 +329,7 @@ const Button = ({ onPressOut={hasPassedTouchHandler ? handlePressOut : undefined} delayLongPress={delayLongPress} aria-label={ariaLabel} + aria-expanded={ariaExpanded} accessibilityHint={accessibilityHint} role={role} aria-disabled={disabled} diff --git a/src/components/__tests__/Button.test.tsx b/src/components/__tests__/Button.test.tsx index 7ea496a419..b836d37849 100644 --- a/src/components/__tests__/Button.test.tsx +++ b/src/components/__tests__/Button.test.tsx @@ -24,6 +24,21 @@ it('renders text button by default', async () => { expect(tree).toMatchSnapshot(); }); +it.each([true, false])( + 'exposes aria-expanded=%s on the interactive button', + async (expanded) => { + await render( + + ); + + expect( + screen.getByRole('button', { name: 'Show details', expanded }) + ).toBeEnabled(); + } +); + it('renders text button with mode', async () => { const tree = ( await render()