react-native-root-toast icon indicating copy to clipboard operation
react-native-root-toast copied to clipboard

Accessibility

Open maki3000 opened this issue 4 years ago • 4 comments

What's the state with accessibility in this package? Is accessibilityRole="alert" set? I would really appreciate it!

Could we add:

  • accessibilityLabel
  • accessibilityHint

maki3000 avatar Feb 10 '21 16:02 maki3000

PRs are welcomed

sunnylqm avatar Feb 10 '21 16:02 sunnylqm

I will try soon to do that!

I guess will do the following in lib/ToastContainer.js:

...
static defaultProps = {
        visible: false,
        duration: durations.SHORT,
        animation: true,
        shadow: true,
        position: positions.BOTTOM,
        opacity: 0.8,
        delay: 0,
        hideOnPress: true,
        keyboardAvoiding: true,
        accessible: true,
        accessibilityLabel: undefined,
        accessibilityHint: undefined,
        accessibilityRole: "alert"
    };
...
<TouchableWithoutFeedback
  onPress={() => {
    typeof this.props.onPress === 'function' ? this.props.onPress() : null
    this.props.hideOnPress ? this._hide() : null
   }}
   accessible={this.props.accessible ? this.props.accessible : true}
   accessibilityLabel={this.props.accessibilityLabel ? this.props.accessibilityLabel : undefined}
   accessibilityHint={this.props.accessibilityHint ? this.props.accessibilityHint : undefined}
   accessibilityRole={this.props.accessibilityRole ? this.props.accessibilityRole : "alert"}
>
...

What do you think?

maki3000 avatar Feb 10 '21 16:02 maki3000

@sunnylqm He did it here. Any luck to be merged ?

seba9999 avatar Mar 08 '22 09:03 seba9999

import { AccessibilityInfo } from "react-native";

  Toast.show(message, {
    duration: Toast.durations.SHORT,
    position: Toast.positions.BOTTOM,
    shadow: true,
    animation: true,
    hideOnPress: true,
    delay: 0,
    textColor: "black",
    containerStyle: { height: 48 },
    opacity: 1,


    onShow: () => {
      // calls on toast\`s appear animation start

      AccessibilityInfo.announceForAccessibility(message); //<--------------- add this line

    },

  });

AHMED-5G avatar Feb 20 '23 04:02 AHMED-5G