Skip to content

Commit b698ebc

Browse files
yotsudaclaude
andcommitted
Avalonia shell: wire NewWindowRequested (and clear CS0067)
target=_blank / window.open requests are now suppressed and routed through HandleLinkClick (open http(s) in the OS browser, follow local Markdown links in-place), using WebViewNewWindowRequestedEventArgs.Request. The Avalonia project now builds with 0 warnings. Smoke still green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 75c828b commit b698ebc

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

MarkdownPointer.Avalonia/AvaloniaWebViewHost.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,14 @@ public AvaloniaWebViewHost(NativeWebView webView)
2828

2929
_webView.NavigationCompleted += (_, _) => NavigationCompleted?.Invoke();
3030

31-
// NewWindowRequested wiring deferred until the per-OS hosts are verified
32-
// (arg shape differs); the minimal scaffold does not need it.
31+
// target=_blank / window.open: suppress the popup and let the app decide
32+
// (open in the OS browser, or follow a local Markdown link in-place).
33+
_webView.NewWindowRequested += (_, e) =>
34+
{
35+
e.Handled = true;
36+
if (e.Request is { } uri)
37+
NewWindowRequested?.Invoke(uri.ToString());
38+
};
3339
}
3440

3541
public object Control => _webView;

MarkdownPointer.Avalonia/MainWindow.axaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public MainWindow()
4646
_host = new AvaloniaWebViewHost(_webView);
4747
_host.MessageReceived += OnHostMessage;
4848
_host.NavigationCompleted += OnNavigationCompleted;
49+
_host.NewWindowRequested += HandleLinkClick; // target=_blank / window.open
4950

5051
Loaded += (_, _) => { Render(); SetupWatcher(); };
5152
Closed += (_, _) => { _watcher?.Dispose(); _reloadDebounce?.Stop(); };

0 commit comments

Comments
 (0)