Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is no way to add accessibility (https://reactnative.dev/docs/accessibility) to link elements #50

Open
jakthegr8 opened this issue Nov 18, 2020 · 3 comments

Comments

@jakthegr8
Copy link

The markdown is not supporting accessibility(https://reactnative.dev/docs/accessibility) tags. Basically I want to add focus (accessible={true}) for link elements inside the markdown tag, But there is no way to do it.

@satya-imaginea
Copy link

I too have the same issue, switched to webview.

@Laudair
Copy link

Laudair commented May 26, 2022

The children components will respect the parent accessibility role. Which in this case will always be Text.

What you can do is to set the parent component to not have any accessibility role, so that the children components can have their own accessibility props.

In the rules props function, just return the textgroup as react fragment

const rules = (props: Props): RenderRules => {
   return {
      textgroup: (children) => <>{children}</>,
      link: (node, __, ___, ____) => {
         const { content } = node.children[0];
    
            return (
              <Text key={node.key}  accessibilityRole="link" onPress={() => onPress()}>
                   {content}
               </Text>
                );
          },
    }

<MarkdownRenderer style={mergedMarkdownStyle} rules={rules(this.props)}>
          {children}
 </MarkdownRenderer 

@JPGrefaldo
Copy link

I've wrap the component with and it works
i.e.
return ( <View accessible> <Text key={node.key} accessibilityRole="link" onPress={() => onPress()}> {content} </Text> </View>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants