ui-ninja / react-native-rating-element

A simple rating library for react native supporting: decimal points, direction aware icons, custom icon set from Ionicons, custom images and record rating given by users.
MIT License
25 stars 5 forks source link

Add support for accessibility when tapping on rating icon #10

Closed andrewTaylor2 closed 4 years ago

andrewTaylor2 commented 4 years ago

Before raising issue, first thanks for creating this library. ๐Ÿ˜ƒ

During usage of library, I found that when talkback is active,

Thanks!

ui-ninja commented 4 years ago

ahh! a11y is important and I totally missed it ๐Ÿคฆ
Will work on it and update soon .. Thanks for raising the issue

ui-ninja commented 4 years ago

@andrewTaylor2 I have been pretty busy recently. Today only I got some time off to work on a11y.

So reg. a11y.... It was actually a bit tricky as we use background and foreground (colored) icons, So when screen reader is ON, on swipe it was focusing on both icons whereas we want it only on background icons. Else it just focuses and announce same label twice.

But still could manage it, see if you could take a pull the branch and test it.

Also once tapped by user, you may add a custom <Text> component with accessibilityLiveRegion="polite". This will announce user what he just selected. Something like:

const [rating, setRating] = useState(0);
...
...
...
return (
  <View style={styles.card}>
    <Rating
      rated={rating}
      totalCount={5}
      ratingColor="#f1c644"
      ratingBackgroundColor="#d4d4d4"
      size={32}
      icon="add-circle"
      direction="column"
      onIconTap={pos => setRating(pos)}
    />
    <Text accessibilityLiveRegion="polite" accessibilityLabel={`Rating selected ${rating} out of 5`}>{rating}/5 (200)</Text>
  </View>
);

and in end for readonly ratings, it would be better if you could wrap it around your custom View and add a11y labels to it. This way you will have full control for readonly ratings.

andrewTaylor2 commented 4 years ago

Thank you for taking time off and working on this issue. I just forked and tested the branch, it working as expected in my android device ๐ŸŽ‰

When we can expect release for this feature?

ui-ninja commented 4 years ago

a11y ready release v5.3.4 Closing the issue, feel free to reopen

andrewTaylor2 commented 4 years ago

Thanks for release๐ŸŽŠ