From e3ae92234acd2c2ae36dc82a9d4664f9d2a18caf Mon Sep 17 00:00:00 2001 From: Luke Blevins Date: Sat, 11 Apr 2020 16:11:02 -0400 Subject: [PATCH] Fix reported right-click crash --- .../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; }