dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.27k stars 1.76k forks source link

Blank target links no longer works on iOS 18 in BlazorWebView #25602

Open MoienTajik opened 3 weeks ago

MoienTajik commented 3 weeks ago

Description

If you have a MAUI Blazor application and have an a tag in your component, like this:

<a href="https://google.com" target="_blank">Test</a>

Clicking on the a tag with _blank target on iOS 18 causes following error:

[Application] BUG IN CLIENT OF UIKIT: The caller of UIApplication.openURL(_:) needs to migrate to the non-deprecated UIApplication.open(_:options:completionHandler:). Force returning false (NO).

This works fine on iOS 17.5.

Steps to Reproduce

  1. Create a new MAUI Blazor Hybrid App
  2. Put a link with blank target in one of your Blazor components, like this:
    <a href="https://google.com" target="_blank">Test</a>
  3. Run the app and try to click on the link

Version with bug

8.0.92 SR9.2

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

8.0.92 SR9.2

Affected platforms

iOS

Affected platform versions

iOS 18

Relevant log output

[Application] BUG IN CLIENT OF UIKIT: The caller of UIApplication.openURL(_:) needs to migrate to the non-deprecated UIApplication.open(_:options:completionHandler:). Force returning false (NO).
mkArtakMSFT commented 3 weeks ago

Thanks for contacting us. Can you please try to validate this scenario with plain WebView, rather than BlazorWebview and see if the behavior persists?

MoienTajik commented 3 weeks ago

Thanks for contacting us. Can you please try to validate this scenario with plain WebView, rather than BlazorWebview and see if the behavior persists?

No, it only happens with BlazorWebView. Testing that is also easy, create a new MAUI Hybrid App. There's a default MainLayout.razor page that contains an About link to Microsoft, which is now broken on iOS 18:

@inherits LayoutComponentBase

<div class="page">
    <div class="sidebar">
        <NavMenu />
    </div>

    <main>
        <div class="top-row px-4">
            <a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
        </div>

        <article class="content px-4">
            @Body
        </article>
    </main>
</div>

Here's also the sample project, if needed (bug/url-issue branch).

MoienTajik commented 3 weeks ago

For now, a workaround is to use IBrowser and open the link like this:

await Browser.Default.OpenAsync(uri, BrowserLaunchMode.SystemPreferred);
ninachen03 commented 3 weeks ago

This issue has been verified using Visual Studio 17.12.0 Preview 5(8.0.92 & 8.0.3). Can repro this issue at iOS platform. Image