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

React Native WebView onNavigationStateChange event value is incorrect on Android #14585

Closed
fernandofranca opened this issue Jun 18, 2017 · 2 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@fernandofranca
Copy link

fernandofranca commented Jun 18, 2017

Description

Setting document.title and window.location.hash triggers onNavigationStateChange but the values passed into onNavigationStateChange aren't the same.

This behaviour isn't consistent with a real device and the Expo simulator.

The wrong behaviour can also be seen on Android 5.0.0 Genymotion Simulator.

I've just opened the snack on my device and it has the expected behaviour.

This issue seems to be related to tooling. I dont't know which part of the tooling should be responsible.

Ex.:
Script on the WebView modifies document.title and window.location:

function updateHeight() {
    document.title = wrapper.clientHeight;
    window.location.hash = ++i;
}

Results for Android device:

{
title:"data:text/html; charset=utf-8,<body>...", 
url:"data:text/html; charset=utf-8,<body>..."
}

Reproduction Steps

Here: https://gist.github.com/epeli/10c77c1710dd137a1335

Sample Code

https://snack.expo.io/HkKOaHV7W

It must print a integer value below the WebView.

Note: Behaviour on simulator isn't consistent with a real device.

Additional Information

  • React Native version: react-native: 0.44.2
  • Platform: Android 6.0 and 5.0 (didn't tested on previous versions)
  • Development Operating System: macOS 10.12.4
  • Build tools: Xcode 8.3.3, Android Studio 2.3
@hramos hramos added the Icebox label Aug 24, 2017
@hramos
Copy link
Contributor

hramos commented Aug 24, 2017

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

@hramos hramos closed this as completed Aug 24, 2017
@YangShaoyue
Copy link

@fernandofranca Did you solve the issue ? I encountered the same question just now.

window.addEventListener('load', updateHeight)
window.addEventListener('resize', updateHeight)

It works well on iOS, but the response is the same as yours on Android.
I find out the semicolons issue on Android from other developers, says "javascript engine will not add semicolons automatically on Android"
So, the code below works well on both Android and iOS:

window.addEventListener('load', updateHeight);
window.addEventListener('resize', updateHeight);

hope this helps you :)

@facebook facebook locked as resolved and limited conversation to collaborators Aug 24, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Aug 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants