Skip to content

Commit 1e9ceaf

Browse files
committed
feat: render Segment label and set default accessibility prop values
1 parent fe6dc95 commit 1e9ceaf

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/index.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,21 @@ const SegmentedControl: React.FC<SegmentedControlProps> = ({
213213
tabTranslateAnimatedStyles,
214214
]}
215215
/>
216-
{segments.map((segment, index) => {
216+
{memoizedSegments.map((segment, index) => {
217+
const isSelected = currentIndex === index;
218+
const { label, ...accessibilityProps } = segment;
219+
217220
return (
218221
<Pressable
219222
onPress={() => memoizedTabPressCallback(index)}
220223
key={index}
221224
style={[styles.touchableContainer, pressableWrapper]}
225+
accessibilityState={{ selected: isSelected }}
226+
accessibilityHint={!isSelected ? `Selects ${label} option` : ''}
227+
accessibilityLabel={`${label}, option, ${index + 1} of ${
228+
segments.length
229+
}`}
230+
accessibilityRole="button"
222231
>
223232
<View style={styles.textWrapper}>
224233
<Text
@@ -228,7 +237,7 @@ const SegmentedControl: React.FC<SegmentedControlProps> = ({
228237
: finalisedInActiveTextStyle,
229238
]}
230239
>
231-
{segment}
240+
{label}
232241
</Text>
233242
{badgeValues[index] && (
234243
<View

0 commit comments

Comments
 (0)