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

CanGoBack/Forward return false until WebView is interacted with #4335

Open
stavfx opened this issue Jan 30, 2024 · 1 comment
Open

CanGoBack/Forward return false until WebView is interacted with #4335

stavfx opened this issue Jan 30, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@stavfx
Copy link

stavfx commented Jan 30, 2024

What happened?

Problem:
In some scenarios, CanGoBack / CanGoForward don't reflect the true state, even though HistoryChanged events fire normally.

Details:
I have a UWP app with a WebView2 on the entire page. The app can accept deep links that are forwarded to the web app and handled internally as react-router navigations, so there are valid flows where the user might not interact with the app at all before the webapp changes the history backstack.

Workaround:
To get around this, I trigger some js script execution when the DOM is loaded and the issue is resolved

            webView.CoreWebView2.DOMContentLoaded += async (sender, event) =>
            {
                await webView.CoreWebView2.ExecuteScriptAsync("1");
            };

Importance

Moderate. My app's user experience is affected, but still usable.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

unknown

SDK Version

1.0.2210.55

Framework

WinUI2/UWP

Operating System

Xbox

OS Version

Xbox Series S 10.0.25398.2923

Repro steps

Create a WebView pointing to a local React App with route { path: "/redirect_test/:c", Component: TestRedirect },
Launch the app and wait for redirects to happen.
Property CanGoBack will always return false.

react component to test with:

const TestRedirect = () => {
  const { c } = useParams();
  const navigate = useNavigate();
  useEffect(() => {
    const timer = setTimeout(() => {
        navigate(`../${1 + parseInt(c)}`, { relative: 'path' })
    }, 2000);
    return () => {
      clearTimeout(timer);
    }
  }, [c]);
  return <Text>Redirecting... #{c}</Text>
};

Repros in Edge Browser

Not Applicable

Regression

Don't know

Last working version (if regression)

No response

@stavfx stavfx added the bug Something isn't working label Jan 30, 2024
@llehn
Copy link

llehn commented Feb 24, 2024

Same problem.

I even have a screenshot from CI, where WebView2 reports CanGoBack as false (which fails our test), but with a "go back" button.
test-failed-3

On Windows

Runtime 114.0.1823.79
SDK 1.0.1823.32

This seems to happen in 1 of ~5-10 times.

Will update Runtime and SDK to see if still can repro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants