react-native-segmented-control
react-native-segmented-control copied to clipboard
feat: Adding basic accessibility out of the box
Currently, react-native-segmented-control is not accessible and neither export some props to add labels or hints on text and badges, this small PR adds very very basic accessibility out of the box.
LGTM @AdityaPahilwani, and on a different note do you think we need to export the accessibility props?
Yes that could be a nice addition.
I was thinking of adding 2 props for accessible segmentAccessibilityLabel: Array of strings representing accessibilityLabel for segments segmentAccessibilityHint: Array of strings representing accessibilityHint or segments
do you think equivalent of accessibilityrole, accessibilityState would make sense?
Too many props as an array would make it odd as for the component. Need to think of a better way to get this done, I guess. I feel there are already too many props. If there isn't a way. We will have to create separate props for the same. Do you think changing the segments array into an array of objects would simplify this?
initially, I thought about the same but changing the segments array into an array of objects would be a breaking change and for someone who isn't using accessibility keys, it would be a little more effort to put the component working.
I think we can go with a mixed approach like either user pass array of labels or array of object, this way we can be backward compatible and give user control on what they want.
Sounds good to me!
I think we should have support for all these in objects, also I would love to pick this task. accessibilitylabel accessibilityhint accessibilityRole accessibilityState
Great @AdityaPahilwani! Will wait for your PR :) Thank you.