Repository navigation
fix(button): forward expanded state to the interactive control #5148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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} | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. verified natively on iPhone simulator:
accessibility tree matches: button reports [non-blocking] |
||||||
| accessibilityHint={accessibilityHint} | ||||||
| role={role} | ||||||
| aria-disabled={disabled} | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nit] RTL 14 has |
||
| } | ||
| ); | ||
|
|
||
| it('renders text button with mode', async () => { | ||
| const tree = ( | ||
| await render(<Button mode="text">Text Button</Button>) | ||
|
|
||


There was a problem hiding this comment.
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'inPropswith a short JSDoc (just likeFAB.tsxdoes)docs only list props declared in
src/components, so right now it has no entry on Button docs page.aria-label&accessibilityHintabove are declared for the same reason