From b54932e93f071c71d41a11779e343ba46d044f3b Mon Sep 17 00:00:00 2001 From: Sandeep Pal <107866004+OS-sandeeppal@users.noreply.github.com> Date: Mon, 27 May 2024 16:52:32 +0530 Subject: [PATCH] RDEV-6978 Fix Crash when webview is not yet added to visual tree (#339) * RDEV-6978 Fix Crash with detaching of tab when proxy is enabled Fix Crash with detaching of tab when proxy is enabled * RDEV-6978 Added comment Added comment * RDEV-6978 Updated comment Updated comment --- Directory.Build.props | 2 +- WebViewControl.Avalonia/WebView.Avalonia.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index a41aba8e..f3eb0c10 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -10,7 +10,7 @@ 2.0.0.0 2.0.0.0 - 2.121.101 + 2.121.102 OutSystems WebViewControl Copyright © OutSystems 2023 diff --git a/WebViewControl.Avalonia/WebView.Avalonia.cs b/WebViewControl.Avalonia/WebView.Avalonia.cs index bcef26f5..79ef1179 100644 --- a/WebViewControl.Avalonia/WebView.Avalonia.cs +++ b/WebViewControl.Avalonia/WebView.Avalonia.cs @@ -92,7 +92,8 @@ internal void InitializeBrowser(int initialWidth, int initialHeight) { /// True if is a system focus event, or false if is a navigation /// protected virtual bool OnSetFocus(bool isSystemEvent) { - var focusedElement = TopLevel.GetTopLevel(this).FocusManager.GetFocusedElement(); + // VisualRoot can be null when webview is not yet added to the Visual tree + var focusedElement = TopLevel.GetTopLevel(this)?.FocusManager.GetFocusedElement(); return !(focusedElement == chromium || focusedElement == this); } }