Browse Source
Fix crashing after opening a uri on browser (#17524)
* Fix crashing after opening a uri on browser
* Update NavigationHelper.cs
pull/17571/head
Steve
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
8 additions and
5 deletions
-
src/Browser/Avalonia.Browser/Interop/NavigationHelper.cs
-
src/Browser/Avalonia.Browser/Storage/BrowserLauncher.cs
-
src/Browser/Avalonia.Browser/webapp/modules/avalonia/navigationHelper.ts
|
|
|
@ -16,7 +16,7 @@ internal static partial class NavigationHelper |
|
|
|
.OnBackRequested() ?? false; |
|
|
|
return Task.FromResult(handled); |
|
|
|
} |
|
|
|
|
|
|
|
[JSImport("globalThis.open")] |
|
|
|
public static partial JSObject? WindowOpen(string uri, string target); |
|
|
|
|
|
|
|
[JSImport("NavigationHelper.openUri", AvaloniaModule.MainModuleName)] |
|
|
|
public static partial bool WindowOpen(string uri, string target); |
|
|
|
} |
|
|
|
|
|
|
|
@ -13,8 +13,7 @@ internal class BrowserLauncher : ILauncher |
|
|
|
|
|
|
|
if (uri.IsAbsoluteUri) |
|
|
|
{ |
|
|
|
var window = NavigationHelper.WindowOpen(uri.AbsoluteUri, "_blank"); |
|
|
|
return Task.FromResult(window is not null); |
|
|
|
return Task.FromResult(NavigationHelper.WindowOpen(uri.AbsoluteUri, "_blank")); |
|
|
|
} |
|
|
|
return Task.FromResult(false); |
|
|
|
} |
|
|
|
|
|
|
|
@ -11,4 +11,8 @@ export class NavigationHelper { |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
public static openUri(uri?: string, target?: string) { |
|
|
|
return !!window.open(uri, target); |
|
|
|
} |
|
|
|
} |
|
|
|
|