Skip to content

Commit

Permalink
Modified value of aria-valuetext for iOS so it correctly announces ta…
Browse files Browse the repository at this point in the history
…bs with VoiceOver
  • Loading branch information
oddballdave committed Jan 22, 2025
1 parent 55a07f4 commit 7e99445
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import React, { FC, useEffect } from 'react'
import styled from 'styled-components/native'

import { ComponentWrapper } from '../../wrapper'
import { PressableOpacityStyle, useTheme } from '../../utils'
import { isIOS, PressableOpacityStyle, useTheme } from '../../utils'

Check failure on line 14 in packages/components/src/components/SegmentedControl/SegmentedControl.tsx

View workflow job for this annotation

GitHub Actions / Lint

Member 'PressableOpacityStyle' of the import declaration should be sorted alphabetically

/**
* Props for {@link SegmentedControl}
Expand Down Expand Up @@ -96,6 +96,13 @@ export const SegmentedControl: FC<SegmentedControlProps> = ({
total: labels.length,
})

const accessibilityValueText = isIOS()
? t('tab') +
', ' +
(isSelected ? t('selected') + ', ' : '') +
a11yListPosition
: a11yListPosition

const textStyle: TextStyle = {
...typography.vadsFontBodyLarge,
fontFamily: isSelected ? 'SourceSansPro-Bold' : 'SourceSansPro-Regular',
Expand All @@ -112,7 +119,7 @@ export const SegmentedControl: FC<SegmentedControlProps> = ({
key={index}
widthPct={`${100 / labels.length}%`}
aria-label={accessibilityLabel}
aria-valuetext={a11yListPosition}
aria-valuetext={accessibilityValueText}
accessibilityHint={a11yHints ? a11yHints[index] : ''}
role={'tab'}
accessibilityState={{ selected: isSelected }}
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/utils/translation/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"leaveAppAlert.title": "Leave the mobile app?",
"listPosition": "{{position}} of {{total}}",
"required": "Required",
"selected": "Selected",
"tab": "Tab",
"tryAgain": "Try again",
"undo": "Undo"
}

0 comments on commit 7e99445

Please sign in to comment.