react-native-segmented-control icon indicating copy to clipboard operation
react-native-segmented-control copied to clipboard

feat: Adding basic accessibility out of the box

Open AdityaPahilwani opened this issue 3 years ago • 7 comments

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.

AdityaPahilwani avatar Jan 16 '22 19:01 AdityaPahilwani

LGTM @AdityaPahilwani, and on a different note do you think we need to export the accessibility props?

Karthik-B-06 avatar Jan 17 '22 09:01 Karthik-B-06

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?

AdityaPahilwani avatar Jan 17 '22 11:01 AdityaPahilwani

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?

image

Karthik-B-06 avatar Jan 17 '22 14:01 Karthik-B-06

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.

AdityaPahilwani avatar Jan 18 '22 09:01 AdityaPahilwani

Sounds good to me!

Karthik-B-06 avatar Jan 18 '22 10:01 Karthik-B-06

I think we should have support for all these in objects, also I would love to pick this task. accessibilitylabel accessibilityhint accessibilityRole accessibilityState

AdityaPahilwani avatar Jan 18 '22 11:01 AdityaPahilwani

Great @AdityaPahilwani! Will wait for your PR :) Thank you.

Karthik-B-06 avatar Jan 18 '22 11:01 Karthik-B-06