From 234a8520c882e59d7c0c2efe49defe3962d7bbbf Mon Sep 17 00:00:00 2001 From: Luke Blevins Date: Sun, 12 Apr 2020 12:31:16 -0400 Subject: [PATCH] Fix reported right-click crash (#578) --- .../NavigationToolbar/ModernNavigationToolbar.xaml.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Files/UserControls/NavigationToolbar/ModernNavigationToolbar.xaml.cs b/Files/UserControls/NavigationToolbar/ModernNavigationToolbar.xaml.cs index eb9f44436470..24d3c41d5886 100644 --- a/Files/UserControls/NavigationToolbar/ModernNavigationToolbar.xaml.cs +++ b/Files/UserControls/NavigationToolbar/ModernNavigationToolbar.xaml.cs @@ -277,10 +277,12 @@ public async void CheckPathInput(ItemViewModel instance, string CurrentInput) private void VisiblePath_LostFocus(object sender, RoutedEventArgs e) { - if (FocusManager.GetFocusedElement() is FlyoutBase || FocusManager.GetFocusedElement() is AppBarButton) { return; } + if (FocusManager.GetFocusedElement() is FlyoutBase || FocusManager.GetFocusedElement() is AppBarButton || FocusManager.GetFocusedElement() is Popup) { return; } - var element = FocusManager.GetFocusedElement() as Control; - if (element.FocusState != FocusState.Programmatic && element.FocusState != FocusState.Keyboard) + var element = FocusManager.GetFocusedElement(); + var elementAsControl = element as Control; + + if (elementAsControl.FocusState != FocusState.Programmatic && elementAsControl.FocusState != FocusState.Keyboard) { App.CurrentInstance.NavigationToolbar.IsEditModeEnabled = false; }