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
4 changes: 3 additions & 1 deletion src/components/Appbar/AppbarContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ const AppbarContent = ({
titleStyle,
]}
numberOfLines={isFlexible ? 2 : 1}
accessible
// With `onPress` the Pressable is the single focus stop and reads the
// title; an accessible Text inside it would be a second stop on Android.
accessible={!onPress}
role={onPress ? 'none' : 'heading'}
maxFontSizeMultiplier={titleMaxFontSizeMultiplier}
>
Expand Down
16 changes: 16 additions & 0 deletions src/components/__tests__/Appbar/Appbar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,22 @@ describe('Appbar modes', () => {
});
});

describe('Appbar.Content accessibility', () => {
it('makes a pressable title a single focus stop', async () => {
await render(<Appbar.Content title="Title" onPress={() => {}} />);

expect(screen.getByRole('button', { name: 'Title' })).toBeOnTheScreen();
expect(screen.getByText('Title')).toHaveProp('accessible', false);
});

it('keeps a static title accessible as a heading', async () => {
await render(<Appbar.Content title="Title" />);

expect(screen.getByRole('heading', { name: 'Title' })).toBeOnTheScreen();
expect(screen.getByText('Title')).toHaveProp('accessible', true);
});
});

describe('Appbar layout', () => {
const layout = (x: number, width: number) => ({
nativeEvent: { layout: { x, y: 0, width, height: 64 } },
Expand Down
Loading