Closed dkjeune closed 2 years ago
Thank you @dkjeune for taking time to fill this report. Unfortunately, the report doesn't provide the least minimal reproduction, not even the HTML that would produce the issue you are reporting. I am going to close the issue now as this is not actionable for us, but if a viable reproduction is to be provided, I will reopen.
Not that it helps, but I'm getting reports of the same (perhaps only some Android devices?), and I was finally able to reproduce it on a Pixel 2 API 30 emulator running Android 11.
I didn't have time to debug this further, but I have a common component that renders html in the app (that uses react-native-render-html) so what I did as a workaround was just to handle onPress manually like so:
<HTML
...
renderersProps={{
a: {
onPress: (_, href) => {
Linking.openURL(href);
},
},
}}
source={{ html }}
/>
@eithe Would you mind providing the HTML code, React Native version and RNRH version that triggered this undesired behavior? I tried with the same emulator configuration as you did, and the link press worked (React Native 0.64). My code snippet looked like this:
<a href="https://google.com/">This is a test</a>
Good point, @jsamr. I must admit I was running RNRH 6.1.0, but I upgraded to 6.3.3 now. RN 0.65.1.
This does not work: This does:
I get that this is quite hard for you to debug, it should be our responsibility to create a minimal example where it fails instead of you having to dig.
Edit: Please ignore the difference on defaultWebViewProps, just something that changed when I removed stuff to simplify the example. Have now tried with no defaultWebViewProps on both tests just to make sure.
Thanks @eithe for providing this additional information. I managed to reproduce the issue by upgrading from RN 0.64 to RN 0.67 on my "sandbox" project that I use for testing! Now I can investigate...
I found the issue. Check the implementation of the default A press handler:
For a reason yet to determine, await Linking.canOpenURL(href)
ceased returning true
for HTTP(S) URIs on Android. This is obviously a bug on React Native side, but I will have to take it into account and provide a fix.
Nice find, @jsamr! Thanks for investigating and thanks again for your efforts on this project, greatly appreciated.
I've opened a ticket on React Native issue tracker https://github.com/facebook/react-native/issues/32960
Fix has been released https://github.com/meliorence/react-native-render-html/releases/tag/v6.3.4
@eithe Thanks for the sponsor and kind feedback, it always lifts one's spirit!
@jsamr How do you access this.state
inside onPress?
const renderersProps = {
a: {
onPress(event, url, htmlAttribs, target) {
if (url.includes('tc')) {
this.setState({showTerms:true,showPrivacy:false})
}else if (url.includes('pv')) {
this.setState({showTerms:false,showPrivacy:true})
}
}
}
}
Decision Table
<yyy>
is not rendered”Good Faith Declaration
Description
When I click on a link on IOS, it open the browser. On Android, nothing happen. Any help ?
React Native Information
RNRH Version
last version
Tested Platforms
Reproduction Platforms
Minimal, Reproducible Example
nope
Additional Notes
No response