diff --git a/src/components/Appbar/AppbarContent.tsx b/src/components/Appbar/AppbarContent.tsx index 92fae42e7d..963a1eb507 100644 --- a/src/components/Appbar/AppbarContent.tsx +++ b/src/components/Appbar/AppbarContent.tsx @@ -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} > diff --git a/src/components/__tests__/Appbar/Appbar.test.tsx b/src/components/__tests__/Appbar/Appbar.test.tsx index 28c927d95a..edda3be06a 100644 --- a/src/components/__tests__/Appbar/Appbar.test.tsx +++ b/src/components/__tests__/Appbar/Appbar.test.tsx @@ -296,6 +296,22 @@ describe('Appbar modes', () => { }); }); +describe('Appbar.Content accessibility', () => { + it('makes a pressable title a single focus stop', async () => { + await render( {}} />); + + 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(); + + 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 } },