Skip to content

Commit fd7c851

Browse files
authored
feat: better accessibility hinting (#817)
1 parent ca72237 commit fd7c851

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

js/SegmentedControl.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const SegmentedControl = ({
3636
fontStyle,
3737
activeFontStyle,
3838
appearance,
39+
accessibilityHintSeperator = 'out of',
3940
}: SegmentedControlProps): React.Node => {
4041
const colorSchemeHook = useColorScheme();
4142
const colorScheme = appearance || colorSchemeHook;
@@ -99,6 +100,7 @@ const SegmentedControl = ({
99100
<SegmentedControlTab
100101
enabled={enabled}
101102
selected={selectedIndex === index}
103+
accessibilityHint={`${index + 1} ${accessibilityHintSeperator} ${values.length}`}
102104
key={index}
103105
value={value}
104106
tintColor={tintColor}

js/SegmentedControlTab.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ type Props = $ReadOnly<{|
2727
activeFontStyle?: FontStyle,
2828
tabStyle?: ViewStyle,
2929
appearance?: 'dark' | 'light' | null,
30+
accessibilityHint?: string,
3031
|}>;
3132

3233
function isBase64(str) {
@@ -45,6 +46,7 @@ export const SegmentedControlTab = ({
4546
activeFontStyle = {},
4647
appearance,
4748
tabStyle,
49+
accessibilityHint,
4850
}: Props): React.Node => {
4951
const colorSchemeHook = useColorScheme();
5052
const colorScheme = appearance || colorSchemeHook;
@@ -88,6 +90,8 @@ export const SegmentedControlTab = ({
8890
style={[styles.container, tabStyle]}
8991
disabled={!enabled}
9092
onPress={onSelect}
93+
accessibilityHint={accessibilityHint}
94+
accessibilityRole="button"
9195
accessibilityState={{selected: selected, disabled: !enabled}}>
9296
<View style={styles.default}>
9397
{typeof value === 'number' || typeof value === 'object' ? (

0 commit comments

Comments
 (0)