Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ const Button = ({
textColor: customTextColor,
children,
'aria-label': ariaLabel,
'aria-expanded': ariaExpanded,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please declare 'aria-expanded' in Props with a short JSDoc (just like FAB.tsx does)

docs only list props declared in src/components, so right now it has no entry on Button docs page. aria-label & accessibilityHint above are declared for the same reason

accessibilityHint,
role = 'button',
hitSlop,
Expand Down Expand Up @@ -328,6 +329,7 @@ const Button = ({
onPressOut={hasPassedTouchHandler ? handlePressOut : undefined}
delayLongPress={delayLongPress}
aria-label={ariaLabel}
aria-expanded={ariaExpanded}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verified natively on iPhone simulator:

Collapsed Expanded
Image Image

accessibility tree matches: button reports value: "expanded". ✅

[non-blocking] accessibilityState & aria-checked/aria-selected still land on the outer Surface so accessibilityState={{ expanded: false }} quietly contradicts this.
worth a follow-up issue?

accessibilityHint={accessibilityHint}
role={role}
aria-disabled={disabled}
Expand Down
15 changes: 15 additions & 0 deletions src/components/__tests__/Button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<Button aria-expanded={expanded} onPress={() => {}}>
Show details
</Button>
);

expect(
screen.getByRole('button', { name: 'Show details', expanded })
).toBeEnabled();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] expanded is asserted by query option (not by toBeEnabled()) so a regression shows up as "element not found" rather than real cause

RTL 14 has toBeExpanded() / toBeCollapsed(). splitting into two cases would assert it directly:

expect(screen.getByRole('button', { name: 'Show details' })).toBeExpanded()

}
);

it('renders text button with mode', async () => {
const tree = (
await render(<Button mode="text">Text Button</Button>)
Expand Down
Loading