Skip to content

Commit 0ef298e

Browse files
authored
Fix: Profile filter dialog closing when putty/powershell console is open (#3222)
* Fix: Focus issue if profile filter is open * Docs: #3219 * Fix: ProfileFilterPopup with focus window
1 parent ef6c33f commit 0ef298e

File tree

12 files changed

+82
-12
lines changed

12 files changed

+82
-12
lines changed

Source/NETworkManager.Settings/ConfigurationInfo.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,27 @@ public bool IsChildWindowOpen
451451
}
452452
}
453453

454+
/// <summary>
455+
/// Private variable for <see cref="IsProfileFilterPopupOpen" />.
456+
/// </summary>
457+
private bool _isProfileFilterPopupOpen;
458+
459+
/// <summary>
460+
/// Indicates if a profile filter popup is open.
461+
/// </summary>
462+
public bool IsProfileFilterPopupOpen
463+
{
464+
get => _isProfileFilterPopupOpen;
465+
set
466+
{
467+
if (value == _isProfileFilterPopupOpen)
468+
return;
469+
470+
_isProfileFilterPopupOpen = value;
471+
OnPropertyChanged();
472+
}
473+
}
474+
454475
/// <summary>
455476
/// Private variable for <see cref="FixAirspace" />.
456477
/// </summary>

Source/NETworkManager/MainWindow.xaml.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,7 @@ private async void LoadProfile(ProfileFileInfo info, bool showWrongPassword = fa
14431443
}, info.Name, showWrongPassword);
14441444

14451445
childWindow.Title = Strings.UnlockProfileFile;
1446-
1446+
14471447
childWindow.DataContext = viewModel;
14481448

14491449
ConfigurationManager.OnDialogOpen();
@@ -2004,10 +2004,16 @@ private async void FocusEmbeddedWindow()
20042004
- Settings are opened
20052005
- Profile file DropDown is opened
20062006
- Application search TextBox is opened
2007+
- Profile filter (tags) popup is opened
20072008
- Dialog over an embedded window is opened (FixAirspace)
20082009
*/
2009-
if (SelectedApplication == null || SettingsViewIsOpen || IsProfileFileDropDownOpened ||
2010+
if (SelectedApplication == null ||
2011+
// MainWindow
2012+
SettingsViewIsOpen ||
2013+
IsProfileFileDropDownOpened ||
20102014
TextBoxApplicationSearchIsFocused ||
2015+
// Global dialogs
2016+
ConfigurationManager.Current.IsProfileFilterPopupOpen ||
20112017
ConfigurationManager.Current.FixAirspace)
20122018
return;
20132019

Source/NETworkManager/ViewModels/AWSSessionManagerHostViewModel.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,8 @@ public ICommand TextBoxSearchLostFocusCommand
599599

600600
private void OpenProfileFilterAction()
601601
{
602+
ConfigurationManager.Current.IsProfileFilterPopupOpen = true;
603+
602604
ProfileFilterIsOpen = true;
603605
}
604606

@@ -1183,6 +1185,11 @@ private void RefreshProfiles()
11831185
IsProfileFilterSet = !string.IsNullOrEmpty(filter.Search) || filter.Tags.Any();
11841186
}
11851187

1188+
public void OnProfileFilterClosed()
1189+
{
1190+
ConfigurationManager.Current.IsProfileFilterPopupOpen = false;
1191+
}
1192+
11861193
public void OnProfileManagerDialogOpen()
11871194
{
11881195
ConfigurationManager.OnDialogOpen();

Source/NETworkManager/ViewModels/PowerShellHostViewModel.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,10 @@ public bool IsProfileFilterSet
233233
OnPropertyChanged();
234234
}
235235
}
236-
236+
237237
private readonly GroupExpanderStateStore _groupExpanderStateStore = new();
238238
public GroupExpanderStateStore GroupExpanderStateStore => _groupExpanderStateStore;
239-
239+
240240
private bool _canProfileWidthChange = true;
241241
private double _tempProfileWidth;
242242

@@ -492,6 +492,8 @@ private void ClearSearchAction()
492492

493493
private void OpenProfileFilterAction()
494494
{
495+
ConfigurationManager.Current.IsProfileFilterPopupOpen = true;
496+
495497
ProfileFilterIsOpen = true;
496498
}
497499

@@ -517,7 +519,7 @@ private void ClearProfileFilterAction()
517519
IsProfileFilterSet = false;
518520
ProfileFilterIsOpen = false;
519521
}
520-
522+
521523
public ICommand ExpandAllProfileGroupsCommand => new RelayCommand(_ => ExpandAllProfileGroupsAction());
522524

523525
private void ExpandAllProfileGroupsAction()
@@ -531,7 +533,7 @@ private void CollapseAllProfileGroupsAction()
531533
{
532534
SetIsExpandedForAllProfileGroups(false);
533535
}
534-
536+
535537
public ICommand OpenSettingsCommand => new RelayCommand(_ => OpenSettingsAction());
536538

537539
private static void OpenSettingsAction()
@@ -674,7 +676,7 @@ private void SetIsExpandedForAllProfileGroups(bool isExpanded)
674676
foreach (var group in Profiles.Groups.Cast<CollectionViewGroup>())
675677
GroupExpanderStateStore[group.Name.ToString()] = isExpanded;
676678
}
677-
679+
678680
private void ResizeProfile(bool dueToChangedSize)
679681
{
680682
_canProfileWidthChange = false;
@@ -766,7 +768,7 @@ private void CreateTags()
766768
ProfileFilterTags.Add(new ProfileFilterTagsInfo(false, tag));
767769
}
768770
}
769-
771+
770772
private void SetProfilesView(ProfileFilterInfo filter, ProfileInfo profile = null)
771773
{
772774
Profiles = new CollectionViewSource
@@ -809,6 +811,11 @@ private void RefreshProfiles()
809811
}, SelectedProfile);
810812
}
811813

814+
public void OnProfileFilterClosed()
815+
{
816+
ConfigurationManager.Current.IsProfileFilterPopupOpen = false;
817+
}
818+
812819
public void OnProfileManagerDialogOpen()
813820
{
814821
ConfigurationManager.OnDialogOpen();
@@ -841,7 +848,7 @@ private void WriteDefaultProfileToRegistry()
841848
private void ProfileManager_OnProfilesUpdated(object sender, EventArgs e)
842849
{
843850
CreateTags();
844-
851+
845852
RefreshProfiles();
846853
}
847854

Source/NETworkManager/ViewModels/PuTTYHostViewModel.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,8 @@ public ICommand TextBoxSearchLostFocusCommand
503503

504504
private void OpenProfileFilterAction()
505505
{
506+
ConfigurationManager.Current.IsProfileFilterPopupOpen = true;
507+
506508
ProfileFilterIsOpen = true;
507509
}
508510

@@ -901,6 +903,11 @@ private void RefreshProfiles()
901903
IsProfileFilterSet = !string.IsNullOrEmpty(filter.Search) || filter.Tags.Any();
902904
}
903905

906+
public void OnProfileFilterClosed()
907+
{
908+
ConfigurationManager.Current.IsProfileFilterPopupOpen = false;
909+
}
910+
904911
public void OnProfileManagerDialogOpen()
905912
{
906913
ConfigurationManager.OnDialogOpen();

Source/NETworkManager/Views/AWSSessionManagerHostView.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@
402402
</Button>
403403
<Popup PlacementTarget="{Binding ElementName=ButtonProfileFilter}"
404404
Placement="Bottom" StaysOpen="False"
405+
Closed="PopupProfileFilter_Closed"
405406
IsOpen="{Binding ProfileFilterIsOpen}"
406407
Width="220">
407408
<Border Background="{DynamicResource MahApps.Brushes.Window.Background}"

Source/NETworkManager/Views/AWSSessionManagerHostView.xaml.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Windows;
1+
using System;
2+
using System.Windows;
23
using System.Windows.Controls;
34
using System.Windows.Input;
45
using MahApps.Metro.Controls.Dialogs;
@@ -54,4 +55,9 @@ public void FocusEmbeddedWindow()
5455
{
5556
_viewModel.FocusEmbeddedWindow();
5657
}
58+
59+
private void PopupProfileFilter_Closed(object sender, EventArgs e)
60+
{
61+
_viewModel.OnProfileFilterClosed();
62+
}
5763
}

Source/NETworkManager/Views/PowerShellHostView.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@
360360
</Button>
361361
<Popup PlacementTarget="{Binding ElementName=ButtonProfileFilter}"
362362
Placement="Bottom" StaysOpen="False"
363+
Closed="PopupProfileFilter_Closed"
363364
IsOpen="{Binding ProfileFilterIsOpen}"
364365
Width="220">
365366
<Border Background="{DynamicResource MahApps.Brushes.Window.Background}"

Source/NETworkManager/Views/PowerShellHostView.xaml.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,9 @@ public void FocusEmbeddedWindow()
6161
{
6262
_viewModel.FocusEmbeddedWindow();
6363
}
64-
}
64+
65+
private void PopupProfileFilter_Closed(object sender, System.EventArgs e)
66+
{
67+
_viewModel.OnProfileFilterClosed();
68+
}
69+
}

Source/NETworkManager/Views/PuTTYHostView.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@
373373
</Button>
374374
<Popup PlacementTarget="{Binding ElementName=ButtonProfileFilter}"
375375
Placement="Bottom" StaysOpen="False"
376+
Closed="PopupProfileFilter_Closed"
376377
IsOpen="{Binding ProfileFilterIsOpen}"
377378
Width="220">
378379
<Border Background="{DynamicResource MahApps.Brushes.Window.Background}"

0 commit comments

Comments
 (0)